Skip to content

Commit 5099df6

Browse files
author
ekultek
committed
fixes the issue
1 parent afc6567 commit 5099df6

File tree

6 files changed

+23
-38
lines changed

6 files changed

+23
-38
lines changed

api_calls/censys.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import requests
2+
import threading
23

4+
import lib.settings
5+
from lib.output import error
36
from lib.errors import AutoSploitAPIConnectionError
4-
from lib.output import (
5-
error,
6-
info
7-
)
87
from lib.settings import (
98
HOST_FILE,
109
API_URLS,
@@ -28,9 +27,9 @@ def censys(self):
2827
"""
2928
connect to the Censys API and pull all IP addresses from the provided query
3029
"""
31-
info("searching Censys with given query '{}'".format(self.query))
3230
discovered_censys_hosts = set()
3331
try:
32+
lib.settings.start_animation("searching Censys with given query '{}'".format(self.query))
3433
req = requests.post(API_URLS["censys"], auth=(self.id, self.token), json={"query": self.query})
3534
json_data = req.json()
3635
for item in json_data["results"]:

api_calls/shodan.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
import requests
44

5+
from lib.settings import start_animation
6+
from lib.output import error
57
from lib.errors import AutoSploitAPIConnectionError
6-
from lib.output import (
7-
error,
8-
info
9-
)
108
from lib.settings import (
119
API_URLS,
1210
HOST_FILE,
@@ -30,7 +28,7 @@ def shodan(self):
3028
"""
3129
connect to the API and grab all IP addresses associated with the provided query
3230
"""
33-
info("searching Shodan with given query '{}'".format(self.query))
31+
start_animation("search Shodan with given query '{}'".format(self.query))
3432
discovered_shodan_hosts = set()
3533
try:
3634
req = requests.get(API_URLS["shodan"].format(query=self.query, token=self.token))

api_calls/zoomeye.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44

55
import requests
66

7+
from lib.settings import start_animation
78
from lib.errors import AutoSploitAPIConnectionError
8-
from lib.output import (
9-
error,
10-
info
11-
)
9+
from lib.output import error
1210
from lib.settings import (
1311
API_URLS,
1412
HOST_FILE,
@@ -59,7 +57,7 @@ def zoomeye(self):
5957
connect to the API and pull all the IP addresses that are associated with the
6058
given query
6159
"""
62-
info("searching ZoomEye with given query '{}'".format(self.query))
60+
start_animation("searching ZoomEye with given query '{}'".format(self.query))
6361
discovered_zoomeye_hosts = set()
6462
try:
6563
token = self.__get_auth()

autosploit.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,8 @@
2222
import shlex
2323
import pickle
2424
import threading
25-
import subprocess
2625
import censysSearch
2726
import shodan
28-
# idk if you're going to need this since retrying is a decorator (see line 410)
29-
# from retrying import retry
3027

3128
from lib.jsonize import load_exploits
3229
from lib.cmdline.cmd import AutoSploitParser

lib/settings.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import socket
55
import getpass
66
import tempfile
7-
import subprocess
7+
# import subprocess
88

99
import psutil
1010

@@ -73,7 +73,10 @@ def write_to_file(data_to_write, filename, mode="a+"):
7373
"""
7474
write data to a specified file, if it exists, ask to overwrite
7575
"""
76+
global stop_animation
77+
7678
if os.path.exists(filename):
79+
stop_animation = True
7780
is_append = lib.output.prompt("would you like to (a)ppend or (o)verwrite the file")
7881
if is_append == "o":
7982
mode = "w"
@@ -162,7 +165,6 @@ def animation(text):
162165
single threaded so that it will not screw with the
163166
current running process
164167
"""
165-
# TODO:/ this will not stop when stop animation is True
166168
global stop_animation
167169
i = 0
168170
while not stop_animation:
@@ -177,5 +179,11 @@ def animation(text):
177179
sys.stdout.flush()
178180
i += 1
179181
time.sleep(0.1)
180-
else:
181-
print("\n")
182+
183+
184+
def start_animation(text):
185+
import threading
186+
187+
t = threading.Thread(target=animation, args=(text,))
188+
t.daemon = True
189+
t.start()

lib/term/terminal.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import os
22
import sys
3-
# import threading
43

54
import lib.settings
65
import lib.output
@@ -10,9 +9,6 @@
109
import api_calls.censys
1110

1211

13-
stop_animation = False
14-
15-
1612
class AutoSploitTerminal(object):
1713

1814
"""
@@ -109,16 +105,14 @@ def gather_hosts(self, query, given_choice=None):
109105
110106
option 2 must be provided
111107
"""
112-
global stop_animation
113-
114108
choice_dict = {
115109
1: api_calls.shodan.ShodanAPIHook,
116110
2: api_calls.zoomeye.ZoomEyeAPIHook,
117111
3: api_calls.censys.CensysAPIHook
118112
}
119113
searching = False
120114
if given_choice is None:
121-
lib.output.info("please choose an API to gather from (choosing two "
115+
lib.output.info("please choose an API to gather from (choosing two or more "
122116
"separate by comma IE; 1,2)")
123117
for i, api in enumerate(lib.settings.API_URLS.keys(), start=1):
124118
print("{}. {}".format(i, api.title()))
@@ -128,23 +122,14 @@ def gather_hosts(self, query, given_choice=None):
128122
while not searching:
129123
try:
130124
choice = int(choice)
131-
# t = threading.Thread(
132-
# target=lib.settings.animation,
133-
# args=("performing lookup for provided query '{}'".format(query),)
134-
# )
135-
# t.daemon = True
136-
# t.start()
137125
if choice == 1:
138126
choice_dict[choice](self.tokens["shodan"][0], query).shodan()
139-
# stop_animation = True
140127
break
141128
elif choice == 2:
142129
choice_dict[choice](query).zoomeye()
143-
# stop_animation = True
144130
break
145131
elif choice == 3:
146132
choice_dict[choice](self.tokens["censys"][1], self.tokens["censys"][0], query).censys()
147-
# stop_animation = True
148133
break
149134
else:
150135
lib.output.warning("invalid option provided")

0 commit comments

Comments
 (0)