Skip to content

Commit 12f3a0f

Browse files
author
Sanjai kumar
authored
Add files via upload
1 parent c8fc644 commit 12f3a0f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1272
-0
lines changed

__init__.py

Whitespace-only changes.

requirements.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
aiofiles>=23.2.1
2+
aiohttp>=3.9.3
3+
art>=6.1
4+
beautifulsoup4>=4.11.1
5+
click>=8.1.7
6+
colorama>=0.4.4
7+
fake_useragent>=1.2.1
8+
Requests>=2.31.0
9+
urllib3>=1.26.18
10+
lxml>=5.1.0

setup.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from setuptools import setup, find_packages
2+
3+
with open("README.md", "r") as fh:
4+
long_description = fh.read()
5+
6+
setup(
7+
name='shodanx',
8+
version='1.0.1',
9+
author='D.Sanjai Kumar',
10+
author_email='bughunterz0047@gmail.com',
11+
description='ShodanX is a tool to gather information of targets using shodan dorks⚡.',
12+
long_description=long_description,
13+
long_description_content_type="text/markdown",
14+
url="https://github.com/sanjai-AK47/ShodanX",
15+
packages=find_packages(),
16+
install_requires=[
17+
'aiofiles>=23.2.1',
18+
'aiohttp>=3.9.1',
19+
'art>=6.1',
20+
'beautifulsoup4>=4.11.1',
21+
'colorama>=0.4.6',
22+
'click>=8.1.7',
23+
'requests>=2.31.0',
24+
'anyio>=4.2.0',
25+
'fake_useragent>=1.2.1',
26+
'lxml>=5.1.0',
27+
'urllib3>=1.26.18'
28+
],
29+
entry_points={
30+
'console_scripts': [
31+
'shodanx = shodanx.shodanx:cli'
32+
]
33+
},
34+
classifiers=[
35+
"Programming Language :: Python :: 3",
36+
"License :: OSI Approved :: MIT License",
37+
"Operating System :: OS Independent",
38+
],
39+
)

shodanx/__init__.py

Whitespace-only changes.
149 Bytes
Binary file not shown.
18 KB
Binary file not shown.

shodanx/modules/__init__.py

Whitespace-only changes.
Binary file not shown.

shodanx/modules/banner/__init__.py

Whitespace-only changes.
Binary file not shown.
Binary file not shown.

shodanx/modules/banner/banner.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env python3
2+
from colorama import Fore,Back,Style
3+
from art import *
4+
import random
5+
import random
6+
7+
8+
red = Fore.RED
9+
10+
green = Fore.GREEN
11+
12+
magenta = Fore.MAGENTA
13+
14+
cyan = Fore.CYAN
15+
16+
mixed = Fore.RED + Fore.BLUE
17+
18+
blue = Fore.BLUE
19+
20+
yellow = Fore.YELLOW
21+
22+
white = Fore.WHITE
23+
24+
reset = Style.RESET_ALL
25+
26+
bold = Style.BRIGHT
27+
28+
colors = [ green, cyan, blue]
29+
30+
random_color = random.choice(colors)
31+
32+
33+
def banner():
34+
35+
tool_name = "shodanX"
36+
37+
fonts = ["big", "ogre", "shadow", "script", "colossal" , "smslant", "graffiti", "slant"]
38+
selected_font = random.choice(fonts)
39+
banner = text2art(f"{tool_name}", font=selected_font)
40+
41+
banner = f"""{banner}
42+
43+
{bold}{white}Author : D.SanjaiKumar @CyberRevoltSecurities{reset}\n"""
44+
45+
46+
47+
return banner

shodanx/modules/config/__init__.py

Whitespace-only changes.
Binary file not shown.
Binary file not shown.

shodanx/modules/config/config.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import appdirs
2+
import os
3+
4+
5+
def config():
6+
7+
try:
8+
9+
dir = appdirs.user_config_dir()
10+
11+
config = f"{dir}/shodanx"
12+
13+
if not os.path.exists(config):
14+
15+
os.makedirs(config)
16+
17+
return config
18+
19+
except Exception as e:
20+
21+
pass

shodanx/modules/core/__init__.py

Whitespace-only changes.
Binary file not shown.
Binary file not shown.

shodanx/modules/core/core.py

Lines changed: 262 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,262 @@
1+
import aiohttp
2+
import asyncio
3+
import aiofiles
4+
from colorama import Fore, Style, Back
5+
from bs4 import XMLParsedAsHTMLWarning, MarkupResemblesLocatorWarning, BeautifulSoup
6+
from requests.packages.urllib3.exceptions import InsecureRequestWarning
7+
import urllib.parse as encoder
8+
from fake_useragent import UserAgent
9+
import warnings
10+
import os
11+
12+
red = Fore.RED
13+
14+
green = Fore.GREEN
15+
16+
magenta = Fore.MAGENTA
17+
18+
cyan = Fore.CYAN
19+
20+
mixed = Fore.RED + Fore.BLUE
21+
22+
blue = Fore.BLUE
23+
24+
yellow = Fore.YELLOW
25+
26+
white = Fore.WHITE
27+
28+
lm = Fore.LIGHTMAGENTA_EX
29+
30+
reset = Style.RESET_ALL
31+
32+
bold = Style.BRIGHT
33+
34+
35+
async def save(url, output):
36+
37+
try:
38+
39+
40+
if output:
41+
42+
43+
44+
if os.path.isfile(output):
45+
46+
filename = output
47+
48+
elif os.path.isdir(output):
49+
50+
filename = os.path.join(output, f"ShodanX_results.txt")
51+
52+
else:
53+
54+
filename = output
55+
56+
else:
57+
58+
59+
filename = "shodanX_results.txt"
60+
61+
62+
async with aiofiles.open(filename, "a") as w:
63+
64+
await w.write(url + '\n')
65+
66+
except KeyboardInterrupt as e:
67+
68+
69+
print(f"\n[{bold}{blue}INFO{reset}]: {bold}{white}ShodanX exits{reset}")
70+
71+
quit()
72+
73+
except asyncio.CancelledError as e:
74+
75+
76+
SystemExit
77+
78+
async def core_request(query, facet, agents, timeout, redirects, username, output):
79+
80+
try:
81+
82+
total = []
83+
84+
encoded = encoder.quote(query)
85+
86+
url = f"https://www.shodan.io/search/facet?query={encoded}&facet={facet}"
87+
88+
if agents:
89+
90+
agent = UserAgent().random
91+
92+
else:
93+
94+
agent = "ShodanX+https://github.com/sanjai-AK47/ShodanX"
95+
96+
headers = {'User-Agent': agent}
97+
98+
redirect = True if redirects else False
99+
100+
101+
async with aiohttp.ClientSession() as session:
102+
103+
async with session.get(url, ssl=False, timeout=timeout, allow_redirects=redirect, headers=headers) as response:
104+
105+
responsed = await response.text()
106+
107+
108+
with warnings.catch_warnings():
109+
110+
111+
warnings.filterwarnings("ignore", category=UserWarning)
112+
113+
warnings.filterwarnings('ignore', category=XMLParsedAsHTMLWarning)
114+
115+
warnings.filterwarnings("ignore", category=MarkupResemblesLocatorWarning)
116+
117+
soup = BeautifulSoup(responsed, "lxml")
118+
119+
120+
121+
results = soup.find_all('strong')
122+
123+
for result in results:
124+
125+
total.append(result.get_text())
126+
127+
if len(total) == 0:
128+
129+
print(f"[{bold}{red}ALERT{reset}]: {bold}{white}Sorry {username} There is no data available for your queries and facet in shodan{reset}")
130+
131+
quit()
132+
133+
134+
print(f"""[{bold}{blue}INFO{reset}]: {bold}{white}Results Found for your query and facet: {query} & facet:"{facet}"{reset}""")
135+
136+
137+
for result in total:
138+
139+
140+
print(f"[{bold}{blue}INFO{reset}]: {bold}{white}{result}{reset}")
141+
142+
await save(result, output)
143+
144+
print(f"[{bold}{blue}INFO{reset}]: {bold}{white}Total Results Found: {len(total)}{reset}")
145+
146+
147+
except KeyboardInterrupt as e:
148+
149+
print(f"[{blue}INFO{reset}]: {bold}{white}ShodanX exits..{reset}")
150+
151+
SystemExit
152+
153+
except aiohttp.ClientConnectionError as e:
154+
155+
print(f"[{bold}{red}INFO{reset}]: {bold}{white}Client Connection Exceeds for: {url} , {username} please try again your query{reset}")
156+
157+
except asyncio.TimeoutError as e:
158+
159+
print(f"[{bold}{red}INFO{reset}]: {bold}{white}Client Timeout Exceeds for: {url}, {username} please try again your query{reset}")
160+
161+
except asyncio.CancelledError as e:
162+
163+
SystemExit
164+
165+
except Exception as e:
166+
167+
pass
168+
169+
170+
async def enum_request(query, agents, timeout, redirects, username, output):
171+
172+
try:
173+
174+
total = []
175+
176+
url = f"https://www.shodan.io/domain/{query}"
177+
178+
if agents:
179+
180+
agent = UserAgent().random
181+
182+
else:
183+
184+
agent = "ShodanX+https://github.com/sanjai-AK47/ShodanX"
185+
186+
headers = {'User-Agent': agent}
187+
188+
redirect = True if redirects else False
189+
190+
191+
async with aiohttp.ClientSession() as session:
192+
193+
async with session.get(url, ssl=False, timeout=timeout, allow_redirects=redirect, headers=headers) as response:
194+
195+
responsed = await response.text()
196+
197+
if response.status != 200:
198+
199+
print(f"[{bold}{red}ALERT{reset}]: {bold}{white}Sorry {username} unable to fetch subdomains for {query} because of bad response from shodan: {response.status}{reset}")
200+
201+
quit()
202+
203+
204+
with warnings.catch_warnings():
205+
206+
207+
warnings.filterwarnings("ignore", category=UserWarning)
208+
209+
warnings.filterwarnings('ignore', category=XMLParsedAsHTMLWarning)
210+
211+
warnings.filterwarnings("ignore", category=MarkupResemblesLocatorWarning)
212+
213+
soup = BeautifulSoup(responsed, "lxml")
214+
215+
ul = soup.find('ul', id='subdomains')
216+
217+
if ul:
218+
219+
subdomains = ul.findAll("li")
220+
221+
for result in subdomains:
222+
223+
subdomain = result.text.strip() + f".{query}"
224+
225+
print(f"[{bold}{blue}INFO{reset}]: {bold}{white}{subdomain}{reset}")
226+
227+
await save(subdomain, output)
228+
229+
print(f"[{bold}{blue}INFO{reset}]: {bold}{white}Total Subdomains found for {query}: {len(subdomains)}{reset}")
230+
231+
else:
232+
233+
print(f"[{bold}{red}ALERT{reset}]: {bold}{white}Sorry {username} unable to fetch subdomains for {query} because of bad response from shodan{reset}")
234+
235+
236+
237+
except KeyboardInterrupt as e:
238+
239+
print(f"[{blue}INFO{reset}]: {bold}{white}ShodanX exits..{reset}")
240+
241+
SystemExit
242+
243+
except aiohttp.ClientConnectionError as e:
244+
245+
print(f"[{bold}{red}INFO{reset}]: {bold}{white}Client Connection Exceeds for: {url} , {username} please try again for subdomain enumeration{reset}")
246+
247+
except asyncio.TimeoutError as e:
248+
249+
print(f"[{bold}{red}INFO{reset}]: {bold}{white}Client Timeout Exceeds for: {url}, {username} please try again for subdomain enumeration{reset}")
250+
251+
except asyncio.CancelledError as e:
252+
253+
SystemExit
254+
255+
except Exception as e:
256+
257+
print(e)
258+
259+
260+
261+
262+

shodanx/modules/help/__init__.py

Whitespace-only changes.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)