├── .gitignore
├── README.md
├── config
├── lcd_controller.py
├── nsclient.py
├── nsserver.py
├── setup.py
├── shutdown.py
├── source
├── Adafruit_CharLCD.py
├── __init__.py
├── __init__.pyc
├── core.py
└── core.pyc
├── startup
├── lcd_controller
├── shutdown
├── startup_network_scout_client
└── startup_network_scout_server
├── stuff
├── artilleryfunction
├── mysqltablecreator.py
├── mysqlunitstaller.py
├── recievedinfo
└── webinfo
├── website
├── scout.php
└── scoutserver.css
└── website_phponly
├── scout.php
└── scoutserver.css
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | *.pyc
3 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Network Scout
2 | ==
3 |
4 | Network-Scout (NS) is an extension to Artillery. NS allows you to access log files from multiple clients.
5 |
6 | Network-Scout (NS) is designed to run on Raspberry Pi hardware running Raspbian. Network-Scout (NS) might work on other hardware and linux distros but it is untested. Network-Scout (NS) will not run on Windows.
7 |
8 | Network-Scout is a python program, allowing artillery to send logs to a centralized server. Network Scout has a pre-built client and server side. Network Scout can easily be set up using the provided setup script.
9 |
10 | ###
11 | Notes:
12 | Network-Scout must be ran from the home directory. To setup NS, do the following:
13 |
14 |
Download Network Scout
15 |
Type "cd"
16 |
Type "sudo python ns/nssetup.py"
17 |
Follow the instructions
18 |
19 | Setup script works with server and client sides.
20 |
21 |
22 | Startup folder has all the init scripts for the following services:
23 |
24 |
shutdown_button
25 |
lcd_controller
26 |
nsserver (server side only)
27 |
nsclient (server side only)
28 |
29 | All services have the following functionality [start|stop|restart|status]
30 |
--------------------------------------------------------------------------------
/config:
--------------------------------------------------------------------------------
1 | #########################################################################################
2 | # Configuration File #
3 | # Network-Scout #
4 | #########################################################################################
5 | #Server Network Address
6 | IP_SERVER_ADDRESS="192.0.0.0"
7 |
--------------------------------------------------------------------------------
/lcd_controller.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | ##################################################################
3 | #Network-Scout - An Addition to Artillery
4 | #An artillery logging and web interface
5 | #By Shawn Jordan and Aedan Somerville
6 | #Special thanks to Dave Kennedy, DOW Chemical Co., Marshall University
7 | #Adafruit, Jusbour and the Open Source Community
8 | ########################## GO HERD ###############################
9 | ##################################################################
10 |
11 | import time, os, subprocess, re
12 | from Adafruit_CharLCD import Adafruit_CharLCD
13 | import RPi.GPIO as GPIO
14 |
15 | lcd = Adafruit_CharLCD()
16 | lcd.begin(16,1)
17 | message = ' '
18 |
19 | #Discovers if artillery is running
20 | def artillery_status():
21 | proc = subprocess.Popen("ps aux | grep artillery.py", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
22 | stdout = proc.communicate()
23 |
24 | try:
25 | for line in stdout:
26 | match = re.search("/var/artillery/artillery.py", line) or re.search("python nsserver.py", line)
27 |
28 | if match:
29 | message = 'Artillery...Okay\n'
30 | return message
31 | else:
32 | message = "Artillery...Down\n"
33 | return message
34 |
35 | except Exception:
36 | message = "Artillery..Error\n"
37 | return message
38 |
39 | #Discovers if Network-Scout Server is running
40 | def nsserver_status():
41 | proc = subprocess.Popen("ps aux | grep nsserver.py", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
42 | stdout = proc.communicate()
43 |
44 | try:
45 |
46 | for line in stdout:
47 | match = re.search("python /var/networkscout/nsserver.py", line) or re.search("python nsserver.py", line)
48 |
49 | if match:
50 | message = 'Server...Okay\n'
51 | return message
52 | else:
53 | message = "Server...Down\n"
54 | return message
55 |
56 | except Exception:
57 | message = "Server..Error\n"
58 | return message
59 |
60 | #Determines whether to use artillery function or NS function
61 | if os.path.isdir("/var/artillery/"):
62 | while True:
63 |
64 | #setting variables
65 | message = ""
66 | cmd = "ip addr show eth0 | grep inet | awk '{print $2}' | cut -d/ -f1"
67 |
68 | #Function that gets ip address
69 | def run_cmd(cmd):
70 | p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
71 | output = p.communicate()[0]
72 | return output
73 |
74 | #Clears the lcd screen
75 | lcd.clear()
76 |
77 | #Sets the variables to be seen on the screen
78 | ipaddr = run_cmd(cmd)
79 | status = artillery_status()
80 |
81 | #Prints the variables to the screen
82 | lcd.message( (status) )
83 | lcd.message( (ipaddr) )
84 |
85 | #Waits 1 minute to update
86 | time.sleep(60)
87 | else:
88 | while True:
89 |
90 | #setting variables
91 | message = ""
92 | cmd = "ip addr show eth0 | grep inet | awk '{print $2}' | cut -d/ -f1"
93 |
94 | #Function that gets ip address
95 | def run_cmd(cmd):
96 | p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
97 | output = p.communicate()[0]
98 | return output
99 |
100 | #Clears the lcd screen
101 | lcd.clear()
102 |
103 | #Sets the variables to be seen on the screen
104 | ipaddr = run_cmd(cmd)
105 | status = nsserver_status()
106 |
107 | #Prints the variables to the screen
108 | lcd.message( (status) )
109 | lcd.message('IP %s' % ( ipaddr ) )
110 |
111 | #Waits one minute to update
112 | time.sleep(60)
113 |
114 |
--------------------------------------------------------------------------------
/nsclient.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 |
3 | ############################################################################
4 | # Network-Scout - An Addition to Artillery #
5 | # An artillery logging and web interface #
6 | # By Shawn Jordan and Aedan Somerville #
7 | # Special thanks to Dave Kennedy, DOW Chemical Co., Marshall University #
8 | # Adafruit, Jusbour and the Open Source Community #
9 | # Version 2.0 "THUNDERING HERD" #
10 | ################################# GO HERD #######################################
11 | #################################################################################
12 |
13 | #!/usr/bin/python
14 | from source import core
15 | import sys, os, subprocess, time
16 |
17 | #Starting Client side programs
18 |
19 | server = core.read_config("IP_SERVER_ADDRESS")
20 |
21 | # check if its installed (from Artillery)
22 | if not os.path.isfile("/var/networkscout/nsclient.py"):
23 | print "[*] Network Scout is not installed, running setup.py.."
24 | subprocess.Popen("python network_scout_setup.py", shell=True).wait()
25 | sys.exit()
26 |
27 | else:
28 | while True:
29 | log_size = os.stat("/var/artillery/log/logs.txt").st_size
30 | if log_size < 10:
31 | pass
32 | else:
33 | try:
34 | #Function sends the information to the server defined in the CONFIG file
35 | core.send_log_to_server("/var/artillery/log/logs.txt", (server) )
36 |
37 | #Clears data from log once the data has been sent
38 | art_log = open("/var/artillery/log/logs.txt",'w')
39 | art_log.write(" ")
40 | art_log.close()
41 |
42 | except Exception, e:
43 | print("Network scout had an issue... " + format(e))
44 | pass
45 | except sys.excepthook, e:
46 | print("Network scout had an issue... " + format(e))
47 | pass
48 |
49 | #Waits 1 minute to check log again
50 | time.sleep(60)
51 |
--------------------------------------------------------------------------------
/nsserver.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 |
3 | ############################################################################
4 | # Network-Scout - An Addition to Artillery #
5 | # An artillery logging and web interface #
6 | # By Shawn Jordan and Aedan Somerville #
7 | # Special thanks to Dave Kennedy, DOW Chemical Co., Marshall University #
8 | # Adafruit, Jusbour and the Open Source Community #
9 | # Version 2.0 "THUNDERING HERD" #
10 | ################################# GO HERD #######################################
11 | #################################################################################
12 |
13 | from source import core
14 | import sys, os, subprocess, socket, MySQLdb
15 | #Starting Server side programs
16 |
17 | try:
18 | while True:
19 | #(ASSIGN HOST AND PORT VARIABLES (HOST IS LOCAL, PORT IS 514 DESIGNATED BY -
20 | #ARTILLERY PORT)
21 | HOST = ''
22 | PORT = 514
23 | flag = 1
24 |
25 | #OPEN THE TCP CONNECTION
26 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
27 | s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
28 | s.bind((HOST,PORT))
29 | s.listen(4)
30 | (conn, (ip, port)) = s.accept()
31 | data = conn.recv(2048)
32 |
33 | #RECEIVE DATA FROM TCP CONNECTION
34 | dfile = open("/var/networkscout/stuff/recievedinfo", "w")
35 | dfile.write( (data) )
36 | dfile.close()
37 |
38 | #send back command/message
39 | conn.send("You're message has been recieved.")
40 | conn.close()
41 | s.close()
42 |
43 | ##SETS MYSQL OR FILE CREATION
44 | rpi = core.read_config("IS_R_PI")
45 |
46 | if rpi == "NO":
47 | log_size = os.stat("/var/networkscout/stuff/recievedinfo").st_size
48 | if log_size < 1:
49 | pass
50 | else:
51 | #LOOP OVER THE FILE TO READ ALL THE LINES
52 | of_object = open("/var/networkscout/stuff/recievedinfo", "r")
53 | webinfo = open("/var/networkscout/stuff/webinfo","a")
54 | webinfo.write(of_object)
55 | flag = 0
56 |
57 | #checks to ensure all data is in database
58 | if flag is 1:
59 | pass
60 | else:
61 | cleanfile=open('/var/networkscout/stuff/recievedinfo','w')
62 | cleanfile.write(' ')
63 | cleanfile.close()
64 |
65 | elif rpi == "YES":
66 | log_size = os.stat("/var/networkscout/stuff/recievedinfo").st_size
67 | if log_size < 1:
68 | pass
69 | else:
70 | #LOOP OVER THE FILE TO READ ALL THE LINES
71 | of_object = open("/var/networkscout/stuff/recievedinfo", "r")
72 | loader = file.readlines(of_object)
73 | of_object.close()
74 |
75 | #ASSIGN 0 TO ALL VARIABLES
76 | clip = []
77 | ip = ''
78 | eventtime = ''
79 | alert = ''
80 | mess = ''
81 | flag = 0
82 |
83 | #OPEN DATABASE TO MAKE SERVER CONNECTION
84 | db = MySQLdb.connect("localhost","root","raspberry","Network_Scout")
85 | cursor = db.cursor()
86 |
87 | for shell in loader:
88 | try:
89 | clip = shell.split(',')
90 | ip = clip[0]
91 | eventtime = clip[1]
92 | alert = clip[2]
93 | mess = clip[3]
94 |
95 | #PREPARE SQL QUERY TO INSERT A RECORD INTO THE DATABASE
96 | sql = "INSERT INTO Attacks (rpi_ip,time,alert_level,message) VALUES (\'" + ip + "\',\'" + eventtime + "\',\'" + alert + "\',\'" + mess + "\');"
97 | clip[:] = []
98 |
99 | try:
100 | #EXECUTE THE SQL COMMAND
101 | cursor.execute(sql)
102 | #COMMIT YOUR CHANGES IN THE DATABASE
103 | db.commit()
104 | except Exception, e:
105 | #ROLLBACK IN CASE THERE IS AN ERROR
106 | db.rollback()
107 | print("Error: " + format(e))
108 | print("Database was rolled back...")
109 | flag=1
110 | pass
111 | except:
112 | pass
113 |
114 | #DISCONNECT FROM SERVER
115 | db.close()
116 |
117 | #checks to ensure all data is in database
118 | if flag is 1:
119 | pass
120 | else:
121 | #cleans file when all information is stored in MySQL
122 | cleanfile=open('/var/networkscout/stuff/recievedinfo','w')
123 | cleanfile.write(' ')
124 | cleanfile.close()
125 | else:
126 | raise Error("The config file is incorrectly configured.");
127 |
128 |
129 | except sys.excepthook, e:
130 | print("Network-Scout had an issue... " + format(e))
131 | pass
132 |
133 | except KeyboardInterrupt:
134 | print("Wibbly Wobbly Timey Wimey...Stuff")
135 | sys.exit()
136 |
137 | except Exception, e:
138 | print("Network-Scout had an issue... " + format(e))
139 | pass
140 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 |
3 | ############################################################################
4 | # Network-Scout - An Addition to Artillery #
5 | # An artillery logging and web interface #
6 | # By Shawn Jordan and Aedan Somerville #
7 | # Special thanks to Dave Kennedy, DOW Chemical Co., Marshall University #
8 | # Adafruit, Jusbour and the Open Source Community #
9 | # Version 2.0 "THUNDERING HERD" #
10 | ################################# GO HERD #######################################
11 | #################################################################################
12 |
13 | #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
14 | #INSTALL ARTILLERY BEFORE INSTALLATION
15 | #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16 |
17 | #importing necessary modules for setup
18 | import subprocess, re, os, shutil, sys, time
19 | from source import core
20 |
21 | answer = ''
22 | option = 0
23 | menuopt = 0
24 | isrpi = ''
25 | ismysql = ''
26 |
27 | try:
28 | ###Banners everywhere
29 | print("Welcome to Network-Scout - An addition logging application for Artillery.")
30 | print("If you are installing the client side, please download artillery first.\n")
31 |
32 | print(
33 | """ * * * \n
34 | | / / \n
35 | | / / \n
36 | | / / \n
37 | ____________+___________+______________________+_____\n
38 | NETWORK SCOUT \n
39 | VERSION: 2.0 "THUNDERING HERD" \n
40 | CREATORS: SHAWN JORDAN AND AEDAN SOMERVILLE \n
41 | UPDATED: SEPTEMBER 1, 2015 \n
42 | """)
43 |
44 | ###This allows us to set up Network Scout for raspberry pi or another system
45 | print("First, we need to know if you are building a Raspberry Pi version of Network Scout." )
46 | isrpi = raw_input("Are you using a Raspberry Pi? ")
47 |
48 | ##This adds the config option for Pi onto the file
49 | if answer.lower() == 'y' or answer.lower() == 'yes':
50 | confile = open("config", "a")
51 | confile.write('IS_R_PI="YES"')
52 | confile.close()
53 | else:
54 | confile = open("config", "a")
55 | confile.write('IS_R_PI="NO"')
56 | confile.close()
57 | print("OPTIONS: \n1. Install Network-Scout Server\n2. Install Network-Scout Client \n3. Uninstall Network Scout \n4. Exit")
58 |
59 | ###Menu used for installation of NSServer NSclient and Removal of Network Scout
60 | menuopt = input("Please select one: ")
61 |
62 | if menuopt is 1:
63 | option = 1
64 | pass
65 | elif menuopt is 2 and os.path.isdir("/var/artillery/"):
66 | option = 2
67 | pass
68 | elif menuopt is 2:
69 | print "Please install artillery from github.com/TrustedSec."
70 | sys.exit()
71 | elif menuopt is 3 and os.path.isdir("/var/networkscout/"):
72 | option = 3
73 | pass
74 | elif menuopt is 3:
75 | print "Network-Scout was not detected and could not be uninstalled."
76 | sys.exit()
77 | elif menuopt is 4:
78 | sys.exit()
79 | else:
80 | print "Invalid option. Please try again."
81 | sys.exit()
82 |
83 | if option == 1:
84 | print "[*]********** Network server is preparing to install..."
85 | os.mkdir("/var/networkscout/")
86 | subprocess.Popen("cp -r * /var/networkscout/", shell=True).wait()
87 |
88 | # install to rc.local
89 | print "[*]********** Adding Network-Scout into startup through init scripts..."
90 | if os.path.isdir("/etc/init.d"):
91 | if not os.path.isfile("/etc/init.d/nsserver"):
92 | fileopen = file("startup/startup_network_scout_server", "r")
93 | config = fileopen.read()
94 | filewrite = file("/etc/init.d/nsserver", "w")
95 | filewrite.write(config)
96 | filewrite.close()
97 | print "[*] Triggering update-rc.d on Network Scout to automatic start..."
98 | subprocess.Popen("chmod +x /etc/init.d/nsserver", shell=True).wait()
99 | subprocess.Popen("update-rc.d nsserver defaults", shell=True).wait()
100 |
101 |
102 |
103 | if isrpi.lower() == 'y' or isrpi.lower() == 'yes':
104 | print("[*]********** Downloading LAMP Install Script...")
105 | subprocess.Popen("sudo git clone https://github.com/LikeABoss-001/Raspberry-Pi-LAMP-Install-Script.git", shell=True).wait()
106 | print "[*]********** INSTALLING LAMP..."
107 | print"[!]This may take a few minutes. Feel free to get a coffee. [!]"
108 | subprocess.Popen("sudo chmod +x /home/pi/ns/Raspberry-Pi-LAMP-Install-Script/install.sh && /home/pi/ns/Raspberry-Pi-LAMP-Install-Script/install.sh", shell=True).wait()
109 | subprocess.Popen("rm -rf Raspberry-Pi-LAMP-Install-Script/",shell=True).wait()
110 | subprocess.Popen("sudo apt-get install python-rpi.gpio", shell=True).wait()
111 | print "[*]********** Adding LCD controller into startup through init scripts..."
112 | subprocess.Popen("sudo apt-get install python-rpi.gpio", shell=True).wait()
113 | if os.path.isdir("/etc/init.d"):
114 | if not os.path.isfile("/etc/init.d/lcd_controller"):
115 | fileopen = file("startup/lcd_controller", "r")
116 | config = fileopen.read()
117 | fileopen.close()
118 | filewrite = file("/etc/init.d/lcd_controller", "w")
119 | filewrite.write(config)
120 | filewrite.close()
121 | print "[*] Triggering update-rc.d on LCD Controller to automatic start..."
122 | subprocess.Popen("chmod +x /etc/init.d/lcd_controller", shell=True).wait()
123 | subprocess.Popen("update-rc.d lcd_controller defaults", shell=True).wait()
124 | print "[*]********** Adding Shutdown into startup through init scripts..."
125 | if os.path.isdir("/etc/init.d"):
126 | if not os.path.isfile("/etc/init.d/shutdown_button"):
127 | fileopen = file("startup/shutdown", "r")
128 | config = fileopen.read()
129 | fileopen.close()
130 | filewrite = file("/etc/init.d/shutdown_button", "w")
131 | filewrite.write(config)
132 | filewrite.close()
133 | print "[*] Triggering update-rc.d on Shutdown Button to automatic start..."
134 | subprocess.Popen("chmod +x /etc/init.d/shutdown_button", shell=True).wait()
135 | subprocess.Popen("update-rc.d shutdown_button defaults", shell=True).wait()
136 | subprocess.Popen("chmod 755 /var/networkscout/lcd_controller.py", shell=True).wait()
137 | subprocess.Popen("chmod 755 /var/networkscout/shutdown.py", shell=True).wait()
138 |
139 |
140 | #moving Adafruit into python library
141 | print("*********************** Putting the Pieces Together ********************")
142 | subprocess.Popen("cp /var/networkscout/source/Adafruit_CharLCD.py /usr/lib/python2.7/", shell=True).wait()
143 |
144 | else:
145 | print("We are setting up the website now")
146 | pass
147 |
148 | subprocess.Popen("chmod 755 /var/networkscout/nsserver.py", shell=True).wait()
149 | subprocess.Popen("rm /var/networkscout/nsclient.py", shell=True).wait()
150 |
151 | ####MAY DISCONTINUE DATABASE USAGE FOR NON-PI Users
152 | ismysql = raw_input("Will you be using MySQL? (Y/N) *If not, we will use PHP to create the table* ")
153 | if ismysql.lower() == 'y' or ismysql.lower() == 'yes':
154 | print("************************** Creating Database for Logs ***********************")
155 | subprocess.Popen("sudo apt-get install python-mysqldb", shell=True).wait()
156 | subprocess.Popen("python /var/networkscout/stuff/mysqltablecreator.py", shell=True).wait()
157 | if os.path.isdir("/var/www/html/"):
158 | subprocess.Popen("mv /var/networkscout/website/* /var/www/html/", shell=True).wait()
159 | else:
160 | subprocess.Popen("mv /var/networkscout/website/* /var/www/", shell=True).wait()
161 | else:
162 | if os.path.isdir("/var/www/html/"):
163 | subprocess.Popen("mv /var/networkscout/website_phponly/* /var/www/html/", shell=True).wait()
164 | else:
165 | subprocess.Popen("mv /var/networkscout/website_phponly/* /var/www/", shell=True).wait()
166 |
167 | serverip = core.ipgrab()
168 | print("Website created at "+serverip+"/scoutwebsite.php \n")
169 |
170 | answer=raw_input("Do you wish to reboot your pi? [yes|no] ")
171 | if answer.lower() == 'y' or answer.lower() == 'yes':
172 | subprocess.Popen("reboot", shell=True)
173 | else:
174 | pass
175 |
176 | elif option == 2:
177 | print("[*]********** Installing network-scout...")
178 | core.kill_artillery()
179 | os.mkdir("/var/networkscout")
180 | subprocess.Popen("cp -r ./* /var/networkscout/", shell=True).wait()
181 |
182 |
183 | #modifying artillery
184 | print("[*]**********Modding Artillery for NS logging...")
185 | mod = open("stuff/artilleryfunction", "r")
186 | contents = mod.read()
187 |
188 | artillery = open("/var/artillery/src/core.py", "a")
189 | artillery.write(contents)
190 | artillery.close()
191 | mod.close()
192 |
193 | #Adding nslog to all parts of artillery
194 |
195 | core.modify_program("warn_the_good_guys","/var/artillery/src/harden.py"," nslog(warning)")
196 | core.modify_program("warn_the_good_guys","/var/artillery/src/honeypot.py"," nslog(subject)")
197 | core.modify_program("warn_the_good_guys","/var/artillery/src/monitor.py"," nslog(subject)")
198 | core.modify_program("warn_the_good_guys","/var/artillery/src/ssh_monitor.py"," nslog(subject)")
199 |
200 | print("[*]********** Creating Log Directory and File...")
201 | # create the database directories if they aren't there
202 | if not os.path.isdir("/var/artillery/log/"):
203 | os.makedirs("/var/artillery/log/")
204 | if not os.path.isfile("/var/artillery/log/logs.txt"):
205 | filewrite = file("/var/artillery/log/logs.txt", "w")
206 | filewrite.write(" ")
207 | filewrite.close()
208 |
209 | # install to rc.local
210 | print "[*]********** Adding Network-Scout into startup through init scripts..."
211 |
212 | if os.path.isdir("/etc/init.d"):
213 | if not os.path.isfile("/etc/init.d/nsclient"):
214 | fileopen = file("startup/startup_network_scout_client", "r")
215 | config = fileopen.read()
216 | fileopen.close()
217 | filewrite = file("/etc/init.d/nsclient", "w")
218 | filewrite.write(config)
219 | filewrite.close()
220 | print "[*] Triggering update-rc.d on Network Scout to automatic start..."
221 | subprocess.Popen("chmod +x /etc/init.d/nsclient", shell=True).wait()
222 | subprocess.Popen("update-rc.d nsclient defaults", shell=True).wait()
223 |
224 | if isrpi.lower() == 'y' or isrpi.lower() == 'yes':
225 |
226 | print "[*]********** Adding LCD controller into startup through init scripts..."
227 | subprocess.Popen("sudo apt-get install python-rpi.gpio", shell=True).wait()
228 | if os.path.isdir("/etc/init.d"):
229 | if not os.path.isfile("/etc/init.d/lcd_controller"):
230 | fileopen = file("startup/lcd_controller", "r")
231 | config = fileopen.read()
232 | fileopen.close()
233 | filewrite = file("/etc/init.d/lcd_controller", "w")
234 | filewrite.write(config)
235 | filewrite.close()
236 | print "[*] Triggering update-rc.d on LCD Controller to automatic start..."
237 | subprocess.Popen("chmod +x /etc/init.d/lcd_controller", shell=True).wait()
238 | subprocess.Popen("update-rc.d lcd_controller defaults", shell=True).wait()
239 |
240 | print "[*]********** Adding Shutdown into startup through init scripts..."
241 | if os.path.isdir("/etc/init.d"):
242 | if not os.path.isfile("/etc/init.d/shutdown_button"):
243 | fileopen = file("startup/shutdown", "r")
244 | config = fileopen.read()
245 | fileopen.close()
246 | filewrite = file("/etc/init.d/shutdown_button", "w")
247 | filewrite.write(config)
248 | filewrite.close()
249 | print "[*] Triggering update-rc.d on Shutdown Button to automatic start..."
250 | subprocess.Popen("chmod +x /etc/init.d/shutdown_button", shell=True).wait()
251 | subprocess.Popen("update-rc.d shutdown_button defaults", shell=True).wait()
252 |
253 | subprocess.Popen("chmod 755 /var/networkscout/lcd_controller.py", shell=True).wait()
254 | subprocess.Popen("chmod 755 /var/networkscout/shutdown.py", shell=True).wait()
255 | subprocess.Popen("cp /var/networkscout/source/Adafruit_CharLCD.py /usr/lib/python2.7/", shell=True).wait()
256 |
257 | else:
258 | pass
259 |
260 | print("[*]********** Adding access to scripts for init.d...")
261 | subprocess.Popen("chmod 755 /var/networkscout/nsclient.py", shell=True).wait()
262 | subprocess.Popen("rm /var/networkscout/nsserver.py", shell=True).wait()
263 |
264 | answer=raw_input("Do you wish to reboot your computer? [yes|no] ")
265 | if answer.lower() == 'y' or answer.lower() == 'yes':
266 | subprocess.Popen("reboot", shell=True)
267 | else:
268 | pass
269 | elif option == 3:
270 | answer = raw_input("Do you want to uninstall network-scout: [ yes | no } ")
271 | if answer.lower() == "y" or answer.lower() == "yes":
272 | subprocess.Popen("rm -rf /var/networkscout", shell=True)
273 | if os.path.isfile("/etc/init.d/nsclient"):
274 | os.remove("/etc/init.d/nsclient")
275 | os.remove("/etc/init.d/lcd_controller")
276 | os.remove("/etc/init.d/shutdown_button")
277 | else:
278 | os.remove("/etc/init.d/nsserver")
279 | os.remove("/etc/init.d/lcd_controller")
280 | os.remove("/etc/init.d/shutdown_button")
281 | subprocess.Popen("python /var/networkscout/stuff/mysqluninstaller.py", shell=True)
282 | subprocess.Popen("rm /var/www/*", shell=True)
283 | subprocess.Popen("apt-get purge `dpkg -l | awk -F ' ' ' /php|mysql|otherpackages/ { print $2 } '`", shell=True)
284 |
285 | print "[*] Network-Scout has been uninstalled. Manually kill the process if it is still running."
286 |
287 | else:
288 | print "There was an issue installing Network-Scout."
289 |
290 | except Exception, e:
291 | print("There was an issue installing network-scout") + format(e)
292 | sys.exit()
293 |
--------------------------------------------------------------------------------
/shutdown.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | ##################################################################
3 | #Network-Scout - An Addition to Artillery
4 | #An artillery logging and web interface
5 | #By Shawn Jordan and Aedan Somerville
6 | #Special thanks to Dave Kennedy, DOW Chemical Co., Marshall University
7 | #Adafruit, Jusbour and the Open Source Community
8 | ########################## GO HERD ###############################
9 | ##################################################################
10 |
11 | import RPi.GPIO as GPIO
12 | import time
13 | import os
14 |
15 | GPIO.setmode(GPIO.BCM)
16 | GPIO.setup(4, GPIO.IN,pull_up_down=GPIO.PUD_UP)
17 |
18 | cat = True
19 |
20 | while cat is True:
21 | if(GPIO.input(4) == False):
22 | os.system("sudo shutdown -h now")
23 | GPIO.cleanup()
24 | break
25 | else:
26 | time.sleep(1)
--------------------------------------------------------------------------------
/source/Adafruit_CharLCD.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 |
3 | #
4 | # based on code from lrvick and LiquidCrystal
5 | # lrvic - https://github.com/lrvick/raspi-hd44780/blob/master/hd44780.py
6 | # LiquidCrystal - https://github.com/arduino/Arduino/blob/master/libraries/LiquidCrystal/LiquidCrystal.cpp
7 | #
8 |
9 | from time import sleep
10 |
11 |
12 | class Adafruit_CharLCD(object):
13 |
14 | # commands
15 | LCD_CLEARDISPLAY = 0x01
16 | LCD_RETURNHOME = 0x02
17 | LCD_ENTRYMODESET = 0x04
18 | LCD_DISPLAYCONTROL = 0x08
19 | LCD_CURSORSHIFT = 0x10
20 | LCD_FUNCTIONSET = 0x20
21 | LCD_SETCGRAMADDR = 0x40
22 | LCD_SETDDRAMADDR = 0x80
23 |
24 | # flags for display entry mode
25 | LCD_ENTRYRIGHT = 0x00
26 | LCD_ENTRYLEFT = 0x02
27 | LCD_ENTRYSHIFTINCREMENT = 0x01
28 | LCD_ENTRYSHIFTDECREMENT = 0x00
29 |
30 | # flags for display on/off control
31 | LCD_DISPLAYON = 0x04
32 | LCD_DISPLAYOFF = 0x00
33 | LCD_CURSORON = 0x02
34 | LCD_CURSOROFF = 0x00
35 | LCD_BLINKON = 0x01
36 | LCD_BLINKOFF = 0x00
37 |
38 | # flags for display/cursor shift
39 | LCD_DISPLAYMOVE = 0x08
40 | LCD_CURSORMOVE = 0x00
41 |
42 | # flags for display/cursor shift
43 | LCD_DISPLAYMOVE = 0x08
44 | LCD_CURSORMOVE = 0x00
45 | LCD_MOVERIGHT = 0x04
46 | LCD_MOVELEFT = 0x00
47 |
48 | # flags for function set
49 | LCD_8BITMODE = 0x10
50 | LCD_4BITMODE = 0x00
51 | LCD_2LINE = 0x08
52 | LCD_1LINE = 0x00
53 | LCD_5x10DOTS = 0x04
54 | LCD_5x8DOTS = 0x00
55 |
56 | def __init__(self, pin_rs=25, pin_e=24, pins_db=[23, 17, 27, 22], GPIO=None):
57 | # Emulate the old behavior of using RPi.GPIO if we haven't been given
58 | # an explicit GPIO interface to use
59 | if not GPIO:
60 | import RPi.GPIO as GPIO
61 | GPIO.setwarnings(False)
62 | self.GPIO = GPIO
63 | self.pin_rs = pin_rs
64 | self.pin_e = pin_e
65 | self.pins_db = pins_db
66 |
67 | self.GPIO.setmode(GPIO.BCM)
68 | self.GPIO.setup(self.pin_e, GPIO.OUT)
69 | self.GPIO.setup(self.pin_rs, GPIO.OUT)
70 |
71 | for pin in self.pins_db:
72 | self.GPIO.setup(pin, GPIO.OUT)
73 |
74 | self.write4bits(0x33) # initialization
75 | self.write4bits(0x32) # initialization
76 | self.write4bits(0x28) # 2 line 5x7 matrix
77 | self.write4bits(0x0C) # turn cursor off 0x0E to enable cursor
78 | self.write4bits(0x06) # shift cursor right
79 |
80 | self.displaycontrol = self.LCD_DISPLAYON | self.LCD_CURSOROFF | self.LCD_BLINKOFF
81 |
82 | self.displayfunction = self.LCD_4BITMODE | self.LCD_1LINE | self.LCD_5x8DOTS
83 | self.displayfunction |= self.LCD_2LINE
84 |
85 | # Initialize to default text direction (for romance languages)
86 | self.displaymode = self.LCD_ENTRYLEFT | self.LCD_ENTRYSHIFTDECREMENT
87 | self.write4bits(self.LCD_ENTRYMODESET | self.displaymode) # set the entry mode
88 |
89 | self.clear()
90 |
91 | def begin(self, cols, lines):
92 | if (lines > 1):
93 | self.numlines = lines
94 | self.displayfunction |= self.LCD_2LINE
95 |
96 | def home(self):
97 | self.write4bits(self.LCD_RETURNHOME) # set cursor position to zero
98 | self.delayMicroseconds(3000) # this command takes a long time!
99 |
100 | def clear(self):
101 | self.write4bits(self.LCD_CLEARDISPLAY) # command to clear display
102 | self.delayMicroseconds(3000) # 3000 microsecond sleep, clearing the display takes a long time
103 |
104 | def setCursor(self, col, row):
105 | self.row_offsets = [0x00, 0x40, 0x14, 0x54]
106 | if row > self.numlines:
107 | row = self.numlines - 1 # we count rows starting w/0
108 | self.write4bits(self.LCD_SETDDRAMADDR | (col + self.row_offsets[row]))
109 |
110 | def noDisplay(self):
111 | """ Turn the display off (quickly) """
112 | self.displaycontrol &= ~self.LCD_DISPLAYON
113 | self.write4bits(self.LCD_DISPLAYCONTROL | self.displaycontrol)
114 |
115 | def display(self):
116 | """ Turn the display on (quickly) """
117 | self.displaycontrol |= self.LCD_DISPLAYON
118 | self.write4bits(self.LCD_DISPLAYCONTROL | self.displaycontrol)
119 |
120 | def noCursor(self):
121 | """ Turns the underline cursor off """
122 | self.displaycontrol &= ~self.LCD_CURSORON
123 | self.write4bits(self.LCD_DISPLAYCONTROL | self.displaycontrol)
124 |
125 | def cursor(self):
126 | """ Turns the underline cursor on """
127 | self.displaycontrol |= self.LCD_CURSORON
128 | self.write4bits(self.LCD_DISPLAYCONTROL | self.displaycontrol)
129 |
130 | def noBlink(self):
131 | """ Turn the blinking cursor off """
132 | self.displaycontrol &= ~self.LCD_BLINKON
133 | self.write4bits(self.LCD_DISPLAYCONTROL | self.displaycontrol)
134 |
135 | def blink(self):
136 | """ Turn the blinking cursor on """
137 | self.displaycontrol |= self.LCD_BLINKON
138 | self.write4bits(self.LCD_DISPLAYCONTROL | self.displaycontrol)
139 |
140 | def DisplayLeft(self):
141 | """ These commands scroll the display without changing the RAM """
142 | self.write4bits(self.LCD_CURSORSHIFT | self.LCD_DISPLAYMOVE | self.LCD_MOVELEFT)
143 |
144 | def scrollDisplayRight(self):
145 | """ These commands scroll the display without changing the RAM """
146 | self.write4bits(self.LCD_CURSORSHIFT | self.LCD_DISPLAYMOVE | self.LCD_MOVERIGHT)
147 |
148 | def leftToRight(self):
149 | """ This is for text that flows Left to Right """
150 | self.displaymode |= self.LCD_ENTRYLEFT
151 | self.write4bits(self.LCD_ENTRYMODESET | self.displaymode)
152 |
153 | def rightToLeft(self):
154 | """ This is for text that flows Right to Left """
155 | self.displaymode &= ~self.LCD_ENTRYLEFT
156 | self.write4bits(self.LCD_ENTRYMODESET | self.displaymode)
157 |
158 | def autoscroll(self):
159 | """ This will 'right justify' text from the cursor """
160 | self.displaymode |= self.LCD_ENTRYSHIFTINCREMENT
161 | self.write4bits(self.LCD_ENTRYMODESET | self.displaymode)
162 |
163 | def noAutoscroll(self):
164 | """ This will 'left justify' text from the cursor """
165 | self.displaymode &= ~self.LCD_ENTRYSHIFTINCREMENT
166 | self.write4bits(self.LCD_ENTRYMODESET | self.displaymode)
167 |
168 | def write4bits(self, bits, char_mode=False):
169 | """ Send command to LCD """
170 | self.delayMicroseconds(1000) # 1000 microsecond sleep
171 | bits = bin(bits)[2:].zfill(8)
172 | self.GPIO.output(self.pin_rs, char_mode)
173 | for pin in self.pins_db:
174 | self.GPIO.output(pin, False)
175 | for i in range(4):
176 | if bits[i] == "1":
177 | self.GPIO.output(self.pins_db[::-1][i], True)
178 | self.pulseEnable()
179 | for pin in self.pins_db:
180 | self.GPIO.output(pin, False)
181 | for i in range(4, 8):
182 | if bits[i] == "1":
183 | self.GPIO.output(self.pins_db[::-1][i-4], True)
184 | self.pulseEnable()
185 |
186 | def delayMicroseconds(self, microseconds):
187 | seconds = microseconds / float(1000000) # divide microseconds by 1 million for seconds
188 | sleep(seconds)
189 |
190 | def pulseEnable(self):
191 | self.GPIO.output(self.pin_e, False)
192 | self.delayMicroseconds(1) # 1 microsecond pause - enable pulse must be > 450ns
193 | self.GPIO.output(self.pin_e, True)
194 | self.delayMicroseconds(1) # 1 microsecond pause - enable pulse must be > 450ns
195 | self.GPIO.output(self.pin_e, False)
196 | self.delayMicroseconds(1) # commands need > 37us to settle
197 |
198 | def message(self, text):
199 | """ Send string to LCD. Newline wraps to second line"""
200 | for char in text:
201 | if char == '\n':
202 | self.write4bits(0xC0) # next line
203 | else:
204 | self.write4bits(ord(char), True)
205 |
206 |
207 | if __name__ == '__main__':
208 | lcd = Adafruit_CharLCD()
209 | lcd.clear()
210 | lcd.message(" Adafruit 16x2\n Standard LCD")
211 |
--------------------------------------------------------------------------------
/source/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NetworkScout/ns/e6f02e8dbf0200d6551b5c5130984595d0322e45/source/__init__.py
--------------------------------------------------------------------------------
/source/__init__.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NetworkScout/ns/e6f02e8dbf0200d6551b5c5130984595d0322e45/source/__init__.pyc
--------------------------------------------------------------------------------
/source/core.py:
--------------------------------------------------------------------------------
1 | #Core code - Special thanks to Adafruit for help with the LCD Code and Malbury Circuits for the simple button script!
2 | #IMPORT LIBRARIES
3 | import time, os, subprocess, re, sys, socket
4 |
5 | #Code from project artillery
6 | def kill_artillery():
7 | print "[*] Checking to see if Artillery is currently running..."
8 | proc = subprocess.Popen("ps au | grep /var/artillery/artillery.py", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
9 | stdout = proc.communicate()
10 | try:
11 | for line in stdout:
12 | match = re.search("python /var/artillery/artillery.py", line) or re.search("python artillery.py", line)
13 | if match:
14 | print "[*] Killing running version of Artillery.."
15 | line = line.split(" ")
16 | pid = line[6]
17 | subprocess.Popen("kill %s" % (pid), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True).wait()
18 | print "[*] Killed the Artillery process: " + pid
19 | except: pass
20 |
21 |
22 |
23 | #This function will search the file and find the line
24 | def modify_program(lookup,file_name,inserted):
25 | linenum = 0
26 |
27 | with open(file_name) as file:
28 | for num, line in enumerate(file):
29 | if lookup in line:
30 | linenum = num
31 |
32 | f = open(file_name, "r")
33 | contents = f.readlines()
34 | f.close()
35 |
36 | line_num = linenum+1
37 | contents.insert(line_num, inserted)
38 |
39 | f = open(file_name, "w")
40 | contents = "".join(contents)
41 | f.write(contents)
42 | f.close()
43 |
44 | #Modded code from project artillery
45 | def kill_ns_server():
46 | print "[*] Checking to see if Network Scout is currently running..."
47 | proc = subprocess.Popen("ps au | grep /var/networkscout/nsserver.py", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
48 | stdout = proc.communicate()
49 | try:
50 | for line in stdout:
51 | match = re.search("ps -au | grep /var/networkscout/nsserver.py", line) or re.search("python nsserver.py", line)
52 | if match:
53 | print "[*] Killing running version of Network Scout..."
54 | line = line.split(" ")
55 | pid = line[6]
56 | subprocess.Popen("kill %s" % (pid), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True).wait()
57 | print "[*] Killed the Network Scout process: " + pid
58 | except: pass
59 |
60 | def send_log_to_server(log_path,server):
61 | #creating a socket and connecting
62 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
63 | s.connect(( (server), 514))
64 | #opening log to send to server
65 | file = open(log_path, 'r')
66 | contents = file.read()
67 | file.close()
68 | #sending and closing connection
69 | s.send( (contents) )
70 | data = s.recv(2048)
71 | s.close()
72 | return
73 |
74 | def get_config_path():
75 | path = ""
76 | if os.path.isfile("/var/networkscout/config"):
77 | path = "/var/networkscout/config"
78 | if os.path.isfile("config"):
79 | path = "config"
80 | return path
81 |
82 | def read_config(param):
83 | path = get_config_path()
84 | fileopen = file(path, "r")
85 | for line in fileopen:
86 | if not line.startswith("#"):
87 | match = re.search(param + "=", line)
88 | if match:
89 | line = line.rstrip()
90 | line = line.replace('"', "")
91 | line = line.split("=")
92 | fileopen.close()
93 | return line[1]
94 |
95 | def ipgrab():
96 | cmd = "ip addr show eth0 | grep inet | awk '{print $2}' | cut -d/ -f1"
97 | p = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE)
98 | output = p.communicate()[0]
99 | output = output.strip()
100 | return output
101 |
102 |
--------------------------------------------------------------------------------
/source/core.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NetworkScout/ns/e6f02e8dbf0200d6551b5c5130984595d0322e45/source/core.pyc
--------------------------------------------------------------------------------
/startup/lcd_controller:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ### BEGIN INIT INFO
4 | # Provides: lcd_controller
5 | # Required-Start: $remote_fs $syslog
6 | # Required-Stop: $remote_fs $syslog
7 | # Default-Start: 2 3 4 5
8 | # Default-Stop: 0 1 6
9 | # Short-Description: A button to shutdown your pi
10 | # Description: This file should be used to construct scripts to be
11 | # placed in /etc/init.d.
12 | ### END INIT INFO
13 |
14 | # lcd_controller
15 | # description: Controls output of LCD for IP and Status
16 | # processname: lcd_controller
17 |
18 | DAEMON_PATH="/var/networkscout"
19 |
20 | DAEMON=/var/networkscout/lcd_controller.py
21 | DAEMONOPTS=""
22 |
23 | NAME=shutdown_button
24 | DESC="Controls output of LCD for IP and Status"
25 | PIDFILE=/var/run/lcd_controller.pid
26 | SCRIPTNAME=/etc/init.d/lcd_controller
27 |
28 | case "$1" in
29 | start)
30 | printf "%-50s" "Starting LCD Controller..."
31 | cd $DAEMON_PATH
32 | PID=`$DAEMON $DAEMONOPTS > /dev/null 2>&1 & echo $!`
33 | #echo "Saving PID" $PID " to " $PIDFILE
34 | if [ -z $PID ]; then
35 | printf "%s\n" "Fail"
36 | else
37 | echo $PID > $PIDFILE
38 | printf "%s\n" "Ok"
39 | fi
40 | ;;
41 | status)
42 | printf "%-50s" "Checking LCD Controller..."
43 | if [ -f $PIDFILE ]; then
44 | PID=`cat $PIDFILE`
45 | if [ -z "`ps axf | grep ${PID} | grep -v grep`" ]; then
46 | printf "%s\n" "Process dead but pidfile exists"
47 | else
48 | echo "Running"
49 | fi
50 | else
51 | printf "%s\n" "Service not running"
52 | fi
53 | ;;
54 | stop)
55 | printf "%-50s" "Stopping LCD Controller..."
56 | PID=`cat $PIDFILE`
57 | cd $DAEMON_PATH
58 | if [ -f $PIDFILE ]; then
59 | kill -HUP $PID
60 | printf "%s\n" "Ok"
61 | rm -f $PIDFILE
62 | else
63 | printf "%s\n" "pidfile not found"
64 | fi
65 | ;;
66 |
67 | restart)
68 | $0 stop
69 | $0 start
70 | ;;
71 |
72 | *)
73 | echo "Usage: $0 {status|start|stop|restart}"
74 | exit 1
75 | esac
--------------------------------------------------------------------------------
/startup/shutdown:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ### BEGIN INIT INFO
4 | # Provides: shutdown_button
5 | # Required-Start: $remote_fs $syslog
6 | # Required-Stop: $remote_fs $syslog
7 | # Default-Start: 2 3 4 5
8 | # Default-Stop: 0 1 6
9 | # Short-Description: A button to shutdown your pi
10 | # Description: This file should be used to construct scripts to be
11 | # placed in /etc/init.d.
12 | ### END INIT INFO
13 |
14 | # Shutdown button
15 | # description: Shutdown button
16 | # processname: shutdown_button
17 |
18 | DAEMON_PATH="/var/networkscout"
19 |
20 | DAEMON=/var/networkscout/shutdown.py
21 | DAEMONOPTS=""
22 |
23 | NAME=shutdown_button
24 | DESC="Shutdown your pi with a touch of a button"
25 | PIDFILE=/var/run/shutdown_button.pid
26 | SCRIPTNAME=/etc/init.d/shutdown_button
27 |
28 | case "$1" in
29 | start)
30 | printf "%-50s" "Starting Shutdown Button..."
31 | cd $DAEMON_PATH
32 | PID=`$DAEMON $DAEMONOPTS > /dev/null 2>&1 & echo $!`
33 | #echo "Saving PID" $PID " to " $PIDFILE
34 | if [ -z $PID ]; then
35 | printf "%s\n" "Fail"
36 | else
37 | echo $PID > $PIDFILE
38 | printf "%s\n" "Ok"
39 | fi
40 | ;;
41 | status)
42 | printf "%-50s" "Checking Shutdown Button..."
43 | if [ -f $PIDFILE ]; then
44 | PID=`cat $PIDFILE`
45 | if [ -z "`ps axf | grep ${PID} | grep -v grep`" ]; then
46 | printf "%s\n" "Process dead but pidfile exists"
47 | else
48 | echo "Running"
49 | fi
50 | else
51 | printf "%s\n" "Service not running"
52 | fi
53 | ;;
54 | stop)
55 | printf "%-50s" "Stopping Shutdown Button..."
56 | PID=`cat $PIDFILE`
57 | cd $DAEMON_PATH
58 | if [ -f $PIDFILE ]; then
59 | kill -HUP $PID
60 | printf "%s\n" "Ok"
61 | rm -f $PIDFILE
62 | else
63 | printf "%s\n" "pidfile not found"
64 | fi
65 | ;;
66 |
67 | restart)
68 | $0 stop
69 | $0 start
70 | ;;
71 |
72 | *)
73 | echo "Usage: $0 {status|start|stop|restart}"
74 | exit 1
75 | esac
--------------------------------------------------------------------------------
/startup/startup_network_scout_client:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | ### BEGIN INIT INFO
4 | # Provides: Network-Scout Client
5 | # Required-Start: $remote_fs $syslog
6 | # Required-Stop: $remote_fs $syslog
7 | # Default-Start: 2 3 4 5
8 | # Default-Stop: 0 1 6
9 | # Short-Description: Sends logs to a server from artillery
10 | # Description: A client that collect artillery attack logs and send them to a website
11 | ### END INIT INFO
12 |
13 | # Change the next 3 lines to suit where you install your script and what you want to call it
14 | DIR=/var/networkscout
15 | DAEMON=$DIR/nsclient.py
16 | DAEMON_NAME=nsclient
17 |
18 | # Add any command line options for your daemon here
19 | DAEMON_OPTS=""
20 |
21 | # This next line determines what user the script runs as.
22 | # Root generally not recommended but necessary if you are using the Raspberry Pi GPIO from Python.
23 | DAEMON_USER=root
24 |
25 | # The process ID of the script when it runs is stored here:
26 | PIDFILE=/var/run/$DAEMON_NAME.pid
27 |
28 | . /lib/lsb/init-functions
29 |
30 | do_start () {
31 | log_daemon_msg "Starting system $DAEMON_NAME daemon"
32 | start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --user $DAEMON_USER --chuid $DAEMON_USER --startas $DAEMON -- $DAEMON_OPTS
33 | log_end_msg $?
34 | }
35 | do_stop () {
36 | log_daemon_msg "Stopping system $DAEMON_NAME daemon"
37 | start-stop-daemon --stop --pidfile $PIDFILE --retry 10
38 | log_end_msg $?
39 | }
40 |
41 | case "$1" in
42 |
43 | start|stop)
44 | do_${1}
45 | ;;
46 |
47 | restart|reload|force-reload)
48 | do_stop
49 | do_start
50 | ;;
51 |
52 | status)
53 | status_of_proc "$DAEMON_NAME" "$DAEMON" && exit 0 || exit $?
54 | ;;
55 | *)
56 | echo "Usage: /etc/init.d/$DAEMON_NAME {start|stop|restart|status}"
57 | exit 1
58 | ;;
59 |
60 | esac
61 | exit 0
--------------------------------------------------------------------------------
/startup/startup_network_scout_server:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | ### BEGIN INIT INFO
4 | # Provides: Network-Scout Server
5 | # Required-Start: $remote_fs $syslog
6 | # Required-Stop: $remote_fs $syslog
7 | # Default-Start: 2 3 4 5
8 | # Default-Stop: 0 1 6
9 | # Short-Description: A server to collect data from network scout clients
10 | # Description: A server that collects information from network scout client and places it in a database
11 | ### END INIT INFO
12 |
13 | # Change the next 3 lines to suit where you install your script and what you want to call it
14 | DIR=/var/networkscout
15 | DAEMON=$DIR/nsserver.py
16 | DAEMON_NAME=nsserver
17 |
18 | # Add any command line options for your daemon here
19 | DAEMON_OPTS=""
20 |
21 | # This next line determines what user the script runs as.
22 | # Root generally not recommended but necessary if you are using the Raspberry Pi GPIO from Python.
23 | DAEMON_USER=root
24 |
25 | # The process ID of the script when it runs is stored here:
26 | PIDFILE=/var/run/$DAEMON_NAME.pid
27 |
28 | . /lib/lsb/init-functions
29 |
30 | do_start () {
31 | log_daemon_msg "Starting system $DAEMON_NAME daemon"
32 | start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --user $DAEMON_USER --chuid $DAEMON_USER --startas $DAEMON -- $DAEMON_OPTS
33 | log_end_msg $?
34 | }
35 | do_stop () {
36 | log_daemon_msg "Stopping system $DAEMON_NAME daemon"
37 | start-stop-daemon --stop --pidfile $PIDFILE --retry 10
38 | log_end_msg $?
39 | }
40 |
41 | case "$1" in
42 |
43 | start|stop)
44 | do_${1}
45 | ;;
46 |
47 | restart|reload|force-reload)
48 | do_stop
49 | do_start
50 | ;;
51 |
52 | status)
53 | status_of_proc "$DAEMON_NAME" "$DAEMON" && exit 0 || exit $?
54 | ;;
55 | *)
56 | echo "Usage: /etc/init.d/$DAEMON_NAME {start|stop|restart|status}"
57 | exit 1
58 | ;;
59 |
60 | esac
61 | exit 0
--------------------------------------------------------------------------------
/stuff/artilleryfunction:
--------------------------------------------------------------------------------
1 | import datetime
2 |
3 | def nslog(alert):
4 |
5 | def ipgrab():
6 | cmd = "ip addr show eth0 | grep inet | awk '{print $2}' | cut -d/ -f1"
7 | p = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE)
8 | output = p.communicate()[0]
9 | return output
10 |
11 | ip = " "
12 | ip = ipgrab()
13 | ip = ip.replace('\n', '')
14 | time = datetime.datetime.now().strftime("%y-%m-%d-%H-%M-%S")
15 | log = " "
16 |
17 | log = (ip + ',' + time + ',ALERT,' + alert + '\n')
18 |
19 | fl = open("/var/artillery/log/logs.txt",'a')
20 | fl.write( (log) )
21 | fl.close()
22 |
--------------------------------------------------------------------------------
/stuff/mysqltablecreator.py:
--------------------------------------------------------------------------------
1 |
2 | #!/usr/bin/python
3 |
4 | import MySQLdb as mdb
5 | import sys
6 | import getpass
7 |
8 | pword = getpass.getpass("Enter your MySQL password for root:")
9 | cnx = mdb.connect('localhost','root',pword)
10 |
11 | with cnx:
12 | try:
13 | cur = cnx.cursor()
14 | cur.execute ("CREATE DATABASE Network_Scout;")
15 | cur.execute("USE Network_Scout;")
16 | cur.execute("CREATE TABLE Attacks(incident_number INT PRIMARY KEY NOT NULL AUTO_INCREMENT , rpi_ip VARCHAR(16), time VARCHAR(30) NOT NULL, alert_level VARCHAR(20) NOT NULL, message VARCHAR(200) NOT NULL);")
17 | except mdb.Error, e:
18 | cnx.rollback()
19 | print "Error %d: %s" % (e.args[0],e.args[1])
20 | sys.exit(1)
21 |
22 | cnx.close()
--------------------------------------------------------------------------------
/stuff/mysqlunitstaller.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 |
3 | import MySQLdb as mdb
4 | import sys
5 | import getpass
6 |
7 | pword = getpass.getpass("Enter your MySQL password for root:")
8 | cnx = mdb.connect('localhost','root',pword)
9 |
10 | with cnx:
11 | try:
12 | cur = cnx.cursor()
13 | cur.execute ("DROP DATABASE Network_Scout;")
14 | except mdb.Error, e:
15 | cnx.rollback()
16 | print "Error %d: %s" % (e.args[0],e.args[1])
17 | sys.exit(1)
18 |
19 | cnx.close()
--------------------------------------------------------------------------------
/stuff/recievedinfo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NetworkScout/ns/e6f02e8dbf0200d6551b5c5130984595d0322e45/stuff/recievedinfo
--------------------------------------------------------------------------------
/stuff/webinfo:
--------------------------------------------------------------------------------
1 | test,test,test,test,test
2 | test,test,test,test,test
--------------------------------------------------------------------------------
/website/scout.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
7 |
8 |
9 |
10 | Scout-Server
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |