1+ #!/usr/bin/env python3
12import ssl
2- from requests import get
33from bs4 import BeautifulSoup
44from colorama import Fore , init
5- from urllib .request import urlopen
65from jarm .scanner .scanner import Scanner
6+ from urllib .request import urlopen
7+ from urllib3 .exceptions import MaxRetryError
78from traceback import format_exc as print_traceback
89from re import search , sub , match , MULTILINE , IGNORECASE
10+ from requests import get
11+ from requests .exceptions import ConnectionError
912from requests .packages .urllib3 import disable_warnings
1013from requests .packages .urllib3 .exceptions import InsecureRequestWarning
1114from argparse import ArgumentParser , SUPPRESS , HelpFormatter
2225 "help" : "Show this help message and exit."
2326 },
2427 "logs" : {
25- "url_to_check" : "{}[{}>{}] Analyzing target {}{}" ,
28+ "url_to_check" : "{}[{}>{}] Analyzing target {}<{}>{}" ,
29+ "target_alive" : "\t {}[{}>{}] The target {}<{}>{} is alive" ,
30+ "target_not_alive" : "\t {}[{}!{}] The target {}<{}>{} is not alive" ,
2631 "cs_possible" : "\t {}[{}>{}] Possible Cobalt Strike detected using encoded byte" ,
2732 "no_indicator" : "\t {}[{}>{}] No indicator was found in target {}<{}>{} using encoded byte" ,
2833 "get_jarm" : "\t {}[{}>{}] Jarm: {}" ,
@@ -67,6 +72,39 @@ def format_action_invocation(self, action):
6772 return ', ' .join (action .option_strings ) + ' ' + args_string
6873
6974
75+ def target_alive_checker (target : str ) -> bool :
76+ """
77+ check if the target is alive
78+ :param target: target url
79+ :return: True if the target is alive and False if the target is down
80+ """
81+ try :
82+ resp = get (url = target )
83+ if resp .status_code >= 500 :
84+ print (configs ["logs" ]["target_not_alive" ].format (Fore .LIGHTWHITE_EX ,
85+ Fore .LIGHTRED_EX ,
86+ Fore .LIGHTWHITE_EX ,
87+ Fore .LIGHTRED_EX ,
88+ target ,
89+ Fore .LIGHTWHITE_EX ))
90+ return False
91+ print (configs ["logs" ]["target_alive" ].format (Fore .LIGHTWHITE_EX ,
92+ Fore .LIGHTRED_EX ,
93+ Fore .LIGHTWHITE_EX ,
94+ Fore .LIGHTRED_EX ,
95+ target ,
96+ Fore .LIGHTWHITE_EX ))
97+ return True
98+ except ConnectionError or MaxRetryError :
99+ print (configs ["logs" ]["target_not_alive" ].format (Fore .LIGHTWHITE_EX ,
100+ Fore .LIGHTRED_EX ,
101+ Fore .LIGHTWHITE_EX ,
102+ Fore .LIGHTRED_EX ,
103+ target ,
104+ Fore .LIGHTWHITE_EX ))
105+ return False
106+
107+
70108def acquire_jarm (address : str ) -> str :
71109 """
72110 receives a user input, validate itself and get jarm
@@ -150,11 +188,13 @@ def main(args: ArgumentParser) -> None:
150188
151189 for url in urls :
152190 print (configs ["logs" ]["url_to_check" ].format (Fore .LIGHTWHITE_EX ,
153- Fore .LIGHTBLUE_EX ,
191+ Fore .LIGHTRED_EX ,
154192 Fore .LIGHTWHITE_EX ,
155- Fore .LIGHTBLUE_EX ,
193+ Fore .LIGHTRED_EX ,
156194 url ,
157195 Fore .LIGHTWHITE_EX ))
196+ if not target_alive_checker (target = url ):
197+ continue
158198 try :
159199 urlopen (f"{ url } /%0" .strip ().replace ("//%" , "/%" ))
160200 except Exception as error :
@@ -174,7 +214,7 @@ def main(args: ArgumentParser) -> None:
174214 jarm_lookup (jarm_code = jarm )
175215 else :
176216 print (configs ["logs" ]["no_indicator" ].format (Fore .LIGHTWHITE_EX ,
177- Fore .LIGHTBLUE_EX ,
217+ Fore .LIGHTRED_EX ,
178218 Fore .LIGHTWHITE_EX ,
179219 url ))
180220
@@ -194,11 +234,11 @@ def main(args: ArgumentParser) -> None:
194234 disable_warnings (InsecureRequestWarning )
195235 # perform coloroma multiplatform
196236 init (strip = False )
197- print (configs ['logo' ].format (Fore .LIGHTBLUE_EX ,
237+ print (configs ['logo' ].format (Fore .LIGHTRED_EX ,
198238 Fore .LIGHTWHITE_EX ,
199- Fore .LIGHTBLUE_EX ,
239+ Fore .LIGHTRED_EX ,
200240 Fore .LIGHTWHITE_EX ,
201- Fore .LIGHTBLUE_EX ,
241+ Fore .LIGHTRED_EX ,
202242 Fore .LIGHTWHITE_EX ))
203243 main (args = args_ )
204244
0 commit comments