Skip to content
Permalink
Browse files
rework get gid to fit all machines
  • Loading branch information
doyc2 committed Dec 1, 2021
1 parent 17f5786 commit 154965c14974e6f1cf9da6fadf9dd78cbdb80d9e
Showing 1 changed file with 12 additions and 12 deletions.
@@ -2,6 +2,7 @@ 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")
@@ -13,7 +14,6 @@ def menu():
option = (input(
"\n1. IP Address \n2. Username\n3. Hostname\n4. Port Scan \n5. UID 5\n6. Process Id\n7. GID"))
if option == "1":
import socket
hostname = socket.gethostname()
ipv4 = socket.gethostbyname(hostname)
print("\nWhich output would you like to use")
@@ -52,7 +52,6 @@ def menu():
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":
@@ -69,7 +68,6 @@ def menu():
output_file.write(socket.gethostname())
exit()
elif option == "4":
import socket
socket.setdefaulttimeout(2)
s = socket.socket()
target_ip = input('Enter IP in single quotes: ')
@@ -87,7 +85,6 @@ def menu():
elif option == "n":
exit()
elif option == "5":
import os
uid = os.getuid()
print("\nWhich output would you like to use")
output = (input("1. Console\n2. File\n"))
@@ -105,7 +102,6 @@ def menu():
print(uid, file=output_file)
exit()
elif option == "6":
import os
pid = os.getpid()
print("\nWhich output would you like to use")
output = (input("1. Console\n2. File\n"))
@@ -123,15 +119,19 @@ def menu():
print(pid, file=output_file)
exit()
elif option == "7":
import grp, pwd
user = getpass.getuser()
groups = [g.gr_name for g in grp.getgrall() if user in g.gr_mem]
gid = pwd.getpwnam(user).pw_gid
groups.append(grp.getgrgid(gid).gr_name)
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(groups)
print(gid)
print("Do you want to quit or return to menu?")
option = (input("y or n\n"))
if option == "y":
@@ -141,7 +141,7 @@ def menu():
elif output == "2":
with open('output.txt', 'a') as output_file:
output_file.write('\n')
print(groups, file=output_file)
print(gid, file=output_file)
exit()

elif option == "2":

0 comments on commit 154965c

Please sign in to comment.