Skip to content

Commit f944a31

Browse files
authored
Merge pull request #42 from codingo/progress-bar-dev
Progress bar development
2 parents dc48bc6 + a031aba commit f944a31

File tree

6 files changed

+24
-8
lines changed

6 files changed

+24
-8
lines changed

Interlace/interlace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def main():
2121

2222
output.print_banner()
2323

24-
pool = Pool(arguments.threads, build_queue(arguments, output), arguments.timeout, output)
24+
pool = Pool(arguments.threads, build_queue(arguments, output), arguments.timeout, output, arguments.sober)
2525
pool.run()
2626

2727

Interlace/lib/core/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = '1.4.0'
1+
__version__ = '1.5.0'
22

Interlace/lib/core/input.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,11 @@ def setup_parser():
354354
'stripped out.'
355355
)
356356

357+
parser.add_argument(
358+
'--no-bar', '--sober', dest='sober', action='store_true', default=True,
359+
help='If set then progress bar will be stripped out'
360+
)
361+
357362
output_types = parser.add_mutually_exclusive_group()
358363
output_types.add_argument(
359364
'-v', '--verbose', dest='verbose', action='store_true', default=False,

Interlace/lib/threader.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
import threading
22
import subprocess
33
import os
4+
from tqdm import tqdm
45

56

67
class Worker(object):
7-
def __init__(self, queue, timeout, output):
8+
def __init__(self, queue, timeout, output, tqdm):
89
self.queue = queue
910
self.timeout = timeout
1011
self.output = output
12+
self.tqdm = tqdm
1113

1214
def __call__(self):
1315
while True:
1416
try:
1517
# get task from queue
1618
task = self.queue.pop(0)
19+
if self.tqdm:
20+
self.tqdm.update(1)
1721
# run task
1822
self.run_task(task)
1923
except IndexError:
@@ -25,7 +29,7 @@ def run_task(task):
2529

2630

2731
class Pool(object):
28-
def __init__(self, max_workers, queue, timeout, output):
32+
def __init__(self, max_workers, queue, timeout, output, progress_bar):
2933

3034
# convert stdin input to integer
3135
max_workers = int(max_workers)
@@ -43,9 +47,14 @@ def __init__(self, max_workers, queue, timeout, output):
4347
self.output = output
4448
self.max_workers = max_workers
4549

50+
if progress_bar:
51+
self.tqdm = tqdm(total=len(queue))
52+
else:
53+
self.tqdm = False
54+
4655
def run(self):
4756

48-
workers = [Worker(self.queue, self.timeout, self.output) for w in range(self.max_workers)]
57+
workers = [Worker(self.queue, self.timeout, self.output, self.tqdm) for w in range(self.max_workers)]
4958
threads = []
5059

5160

@@ -72,5 +81,5 @@ def run(self):
7281
"sleep 9",
7382
"sleep 1",
7483
"echo 'Char!'"]
75-
p = Pool(4, tasks, 0, 0)
84+
p = Pool(4, tasks, 0, 0, True)
7685
p.run()

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Dependencies will then be installed and Interlace will be added to your path as
3232
| -pL | Specify a list of proxies |
3333
| --proto | Specify protocols that can be used in commands as \_proto\_ |
3434
| -rp | Specify a real port variable that can be used in commands as \_realport\_ |
35+
| --no-bar / --sober | If set then progress bar be stripped out |
3536
| --no-cidr | If set then CIDR notation in a target file will not be automatically be expanded into individual hosts |
3637
| --no-color | If set then any foreground or background colours will be stripped out |
3738
| --silent | If set then only important information will be displayed and banners and other information will be redacted |
@@ -178,5 +179,5 @@ Using the above example, let's assume you want independent scans to be via diffe
178179
Originally written by Michael Skelton ([codingo](https://twitter.com/codingo_)) and Sajeeb Lohani ([sml555](https://twitter.com/sml555_)) with help from Charelle Collett ([@Charcol0x89](https://twitter.com/Charcol0x89)) for threading refactoring and overall approach, and Luke Stephens ([hakluke](https://twitter.com/hakluke)) for testing and approach.
179180

180181
# Contributions
181-
Contributions to this project are very welcome. If you're a newcomer to open source and would like some help in doing so, feel free to reach out to me on twitter ([@codingo_](https://twitter.com/codingo_)) and I'll assist wherever I can.
182+
Contributions to this project are very welcome. If you're a newcomer to open source and would like some help in doing so, feel free to reach out to us on twitter ([@codingo_](https://twitter.com/codingo_)) / ([@sml555_](https://twitter.com/sml555_)) and we'll assist wherever we can.
182183

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
colorclass==2.2.0
2-
netaddr==0.7.19
2+
netaddr==0.7.19
3+
tqdm==4.32.1

0 commit comments

Comments
 (0)