Skip to content
Permalink
Browse files
Merge pull request #1 from doyc2/task1
Task1
  • Loading branch information
doyc2 committed Dec 1, 2021
2 parents 4982570 + 9052a59 commit a4af016b1cc6c12663d75198b014ed7d46ff367d
Show file tree
Hide file tree
Showing 3 changed files with 341 additions and 0 deletions.
@@ -0,0 +1,340 @@
def menu():
while True:
print("The code will now check what operating system you are using")
from sys import platform
import os, socket
if platform == "linux" or platform == "linux2":
print("Operating system = Linux")
print("Please Select The Process You Require")
option = (input("\n1: Enumeration\n2: Privilege Escalation\n"))
if option == "1":
print("Enumeration Selected")
input("Press the enter key to continue")
print("What Method would you like to use")
option = (input(
"\n1. IP Address \n2. Username\n3. Hostname\n4. Port Scan \n5. UID 5\n6. Process Id\n7. GID"))
if option == "1":
hostname = socket.gethostname()
ipv4 = socket.gethostbyname(hostname)
print("\nWhich output would you like to use")
output = (input("1. Console\n2. File\n"))
if output == "1":
print(ipv4)
print("Do you want to quit or return to menu?")
option = (input("y or n\n"))
if option == "y":
menu()
elif option == "n":
exit()
elif output == "2":
with open('output.txt', 'a') as output_file:
output_file.write('\n')
output_file.write(ipv4)
exit()

elif option == "2":
import getpass
username = getpass.getuser()

print("\nWhich output would you like to use")
output = (input("1. Console\n2. File\n"))
if output == "1":
print(username)
print("Do you want to quit or return to menu?")
option = (input("y or n\n"))
if option == "y":
menu()
elif option == "n":
exit()
elif output == "2":
with open('output.txt', 'a') as output_file:
output_file.write('\n')
output_file.write(username)
exit()
elif option == "3":
print("\nWhich output would you like to use")
output = (input("1. Console\n2. File\n"))
if output == "1":
print(socket.gethostname())
print("Do you want to quit or return to menu?")
option = (input("y or n\n"))
if option == "y":
menu()
elif option == "n":
exit()
elif output == "2":
with open('output.txt', 'a') as output_file:
output_file.write('\n')
output_file.write(socket.gethostname())
exit()
elif option == "4":
socket.setdefaulttimeout(2)
s = socket.socket()
target_ip = input('Enter IP in single quotes: ')
for target_port in range(1, 10000):
try:
s.connect((target_ip, target_port))
print('Scan results for target ip: ', target_ip)
print('[+]%d/tcp open' % target_port)
except (Exception, Exception):
print('[-]%d/tcp close' % target_port)
print("Do you want to quit or return to menu?")
option = (input("y or n\n"))
if option == "y":
menu()
elif option == "n":
exit()
elif option == "5":
uid = os.getuid()
print("\nWhich output would you like to use")
output = (input("1. Console\n2. File\n"))
if output == "1":
print(uid)
print("Do you want to quit or return to menu?")
option = (input("y or n\n"))
if option == "y":
menu()
elif option == "n":
exit()
elif output == "2":
with open('output.txt', 'a') as output_file:
output_file.write('\n')
print(uid, file=output_file)
exit()
elif option == "6":
pid = os.getpid()
print("\nWhich output would you like to use")
output = (input("1. Console\n2. File\n"))
if output == "1":
print(pid)
print("Do you want to quit or return to menu?")
option = (input("y or n\n"))
if option == "y":
menu()
elif option == "n":
exit()
elif output == "2":
with open('output.txt', 'a') as output_file:
output_file.write('\n')
print(pid, file=output_file)
exit()
elif option == "7":
gid = os.getgid()
print(gid)

print("Do you want to quit or return to menu?")
option = (input("y or n\n"))
if option == "y":
menu()
elif option == "n":
exit()
print("\nWhich output would you like to use")
output = (input("1. Console\n2. File\n"))
if output == "1":
print(gid)
print("Do you want to quit or return to menu?")
option = (input("y or n\n"))
if option == "y":
menu()
elif option == "n":
exit()
elif output == "2":
with open('output.txt', 'a') as output_file:
output_file.write('\n')
print(gid, file=output_file)
exit()

elif option == "2":

print("Privilege Escalation")
input("Press the enter key to continue")
print("What Method would you like to use")
option = (input("\n1. Admin CMD\n2. Method 2\n3. Method 3\n"))
if option == "1":
print("Do you want to quit or return to menu?")
option = (input("y or n\n"))
if option == "y":
menu()
elif option == "n":
exit()
elif option == "2":
print("Do you want to quit or return to menu?")
option = (input("y or n\n"))
if option == "y":
menu()
elif option == "n":
exit()
elif option == "3":
print("Do you want to quit or return to menu?")
option = (input("y or n\n"))
if option == "y":
menu()
elif option == "n":
exit()
else:
print("Do you want to quit or return to menu?")
option = (input("y or n\n"))
if option == "y":
menu()
elif option == "n":
exit()

elif platform == "win32":
print("Operating system = Windows")
print("Please Select The Process You Require")
option = (input("\n1: Enumeration\n2: Privilege Escalation\n"))
if option == "1":
print("Enumeration Selected")
input("Press the enter key to continue")
print("What Method would you like to use")
option = (input(
"\n1. IP Address \n2. Username\n3. Hostname\n4. Firewall Status\n5. Port Scan\n6. Process ID\n"))
if option == "1":
if option == "1":
import socket
hostname = socket.gethostname()
ipv4 = socket.gethostbyname(hostname)
print("\nWhich output would you like to use")
output = (input("1. Console\n2. File\n"))
if output == "1":
print(ipv4)
print("Do you want to quit or return to menu?")
option = (input("y or n\n"))
if option == "y":
menu()
elif option == "n":
exit()
elif output == "2":
with open('output.txt', 'a') as output_file:
output_file.write('\n')
output_file.write(ipv4)
exit()
elif option == "2":
import getpass
username = getpass.getuser()

print("\nWhich output would you like to use")
output = (input("1. Console\n2. File\n"))
if output == "1":
print(username)
print("Do you want to quit or return to menu?")
option = (input("y or n\n"))
if option == "y":
menu()
elif option == "n":
exit()
elif output == "2":
with open('output.txt', 'a') as output_file:
output_file.write('\n')
output_file.write(username)
exit()
elif option == "3":
import socket
print("\nWhich output would you like to use")
output = (input("1. Console\n2. File\n"))
if output == "1":
print(socket.gethostname())
print("Do you want to quit or return to menu?")
option = (input("y or n\n"))
if option == "y":
menu()
elif option == "n":
exit()
elif output == "2":
with open('output.txt', 'a') as output_file:
output_file.write('\n')
output_file.write(socket.gethostname())
exit()
elif option == "4":
import subprocess
subprocess.check_call('netsh advfirewall show allprofiles')
print("Do you want to quit or return to menu?")
option = (input("y or n\n"))
if option == "y":
menu()
elif option == "n":
exit()
elif option == "5":
import socket
socket.setdefaulttimeout(2)
s = socket.socket()
target_ip = input('Enter IP in single quotes: ')
for target_port in range(1, 10000):
try:
s.connect((target_ip, target_port))
print('Scan results for target ip: ', target_ip)
print('[+]%d/tcp open' % target_port)
except (Exception, Exception):
print('[-]%d/tcp close' % target_port)
print("Do you want to quit or return to menu?")
option = (input("y or n\n"))
if option == "y":
menu()
elif option == "n":
exit()
elif option == "6":
import os
pid = os.getpid()
print("\nWhich output would you like to use")
output = (input("1. Console\n2. File\n"))
if output == "1":
print(pid)
print("Do you want to quit or return to menu?")
option = (input("y or n\n"))
if option == "y":
menu()
elif option == "n":
exit()
elif output == "2":
with open('output.txt', 'a') as output_file:
output_file.write('\n')
print(pid, file=output_file)
exit()
elif option == "2":

print("Privilege Escalation")
input("Press the enter key to continue")
print("What Method would you like to use")
option = (input("\n1. Method 1\n2. Method 2\n3. Method 3\n"))
if option == "1":
import os
import sys
import win32com.shell.shell as shell
ASADMIN = 'asadmin'

if sys.argv[-1] != ASADMIN:
script = os.path.abspath(sys.argv[0])
params = ' '.join([script] + sys.argv[1:] + [ASADMIN])
shell.ShellExecuteEx(lpVerb='runas', lpFile=sys.executable, lpParameters=params)
sys.exit(0)
print("Do you want to quit or return to menu?")
option = (input("y or n\n"))
if option == "y":
menu()
elif option == "n":
exit()
elif option == "2":
print("Do you want to quit or return to menu?")
option = (input("y or n\n"))
if option == "y":
menu()
elif option == "n":
exit()
elif option == "3":
print("Do you want to quit or return to menu?")
option = (input("y or n\n"))
if option == "y":
menu()
elif option == "n":
exit()
else:
print("Do you want to quit or return to menu?")
option = (input("y or n\n"))
if option == "y":
menu()
elif option == "n":
exit()


if __name__ == '__main__':
menu()
BIN +13.5 KB documentation cw2.docx
Binary file not shown.
@@ -0,0 +1 @@
# Task 1

0 comments on commit a4af016

Please sign in to comment.