summaryrefslogtreecommitdiff
path: root/kpov_judge
diff options
context:
space:
mode:
authormp7462@student.uni-lj.si <mp7462@student.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2014-12-15 21:03:50 +0000
committermp7462@student.uni-lj.si <mp7462@student.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2014-12-15 21:03:50 +0000
commit4659d83ee6b84a53fb8fe7368f4168667861706b (patch)
tree22689201ce9108d312ae1cf3733d02ebdf9af406 /kpov_judge
parent5de1272b40fb095b42a6d3e48d5cd8e726c2b290 (diff)
Added nmap and some other things in task() method
git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@81 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414
Diffstat (limited to 'kpov_judge')
-rw-r--r--kpov_judge/tasks/openvpn_simple_smb/task.py39
1 files changed, 36 insertions, 3 deletions
diff --git a/kpov_judge/tasks/openvpn_simple_smb/task.py b/kpov_judge/tasks/openvpn_simple_smb/task.py
index 4ac5f76..86fba69 100644
--- a/kpov_judge/tasks/openvpn_simple_smb/task.py
+++ b/kpov_judge/tasks/openvpn_simple_smb/task.py
@@ -223,11 +223,44 @@ def task(IP_SimpleArbiterVPN, DNS_SimpleArbiterVPN, IP_VPNClient1, DNS_VPNClient
output = sA.before
results['SimpleArbiter_ping_C2'] = output
- # TODO
+ ###
# Check if both clients are connected to the correct VPN
# (check if first 24 bits of IP addr are the same as the server's)
- #sB.sendline('sudo apt-get install nmap --assume-yes')
- #sB.sendline('sudo nmap -sP 10.8.0.0/24')
+ # a.k.a. the YES WE CAN method of checking things
+ # really, really hoping it has root privileges too
+ ###
+ ### Install nmap
+ # Check if root
+ sA.sendline('id -u')
+ sA.prompt()
+ uid = sA.before.split('\n')
+ uid = uid[1].rstrip()
+ #print uid
+ # If is isn't root
+ if ( uid != "0" ):
+ print "SimpleArbiter user must be root to continue with this step (installing nmap mostly)"
+ # If it is, we continue
+ else:
+ ### Install the nmap package
+ # Check if nmap is already installed
+ sA.sendline('dpkg-query -W nmap')
+ sA.prompt()
+ lines = sA.before.split('\n')
+ line = lines[1]
+ # If it isn't
+ if ( len(line.rstrip()) == 4 ): # returns "nmap\r\n" if package isn't installed
+ sA.sendline('apt-get install nmap --assume-yes')
+ # If it is
+ else:
+ sA.sendline('')
+ #sA.wait() # For some reason this hangs
+ sA.expect(".*#") # Expecting a new line prompt (root's prompt ends with a #)
+
+ # Run nmap on the VPN network
+ sA.sendline('nmap -sP 10.8.0.0/24')
+ sA.prompt()
+ results['SimpleArbiter_nmap_results'] = sA.before
+
######