Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Xeroxxhah committed Oct 21, 2022
0 parents commit 0d1be77
Show file tree
Hide file tree
Showing 17 changed files with 1,254 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.dccache
118 changes: 118 additions & 0 deletions 6u4rd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import getpass
from core.auth import Auth
from core.mail import Mailer
from core.misc import Misc
from pyngrok import ngrok
import secrets


helper = Misc()
dummy_password = 'pass'
auth = Auth(dummy_password)
mailer = Mailer()
app_auth = None
email= ''
password = ''
receiver_mail = ''

helper.config_write()

if auth.is_first():
print("Welcome to 6u4rd")

try:
code_name = input(f"Enter code name ({helper.gethost()}): ")
if len(code_name) != 0:
auth.code_name = code_name
auth.create_authkey()
print('-'*50)
print("Authentication Key created: {}".format(dummy_password))
print('-'*50)
ch = input("""
Warning: Sender's Email address and password are being stored in plain text.
Please do NOT use your personal email address and password instead user DUMMY email account.
I understand the risks and i am not using my personal information. (Y/N):
""")
if ch.lower() == "y":
email = input("Enter your email address: ")
password = getpass.getpass("Enter your password: ")
receiver_mail = input("Enter receiver email address: ")
else:
print("Quiting...")
quit()
print("\nSetting up ngrok...")
ngrok_token = input("Enter ngrok token: ")
ngrok.set_auth_token(ngrok_token)
print('\n')
host = input(f'Enter host address ({helper.config["host"]}): ')
host = helper.config["host"] if len(host) == 0 else host
port = input(f'Enter port number: ({helper.config["port"]}): ')
port = helper.config["port"] if len(port) == 0 else port
auth_path = input(f'Enter auth path: ({helper.config["auth_path"]}): ')
auth_path = helper.config["auth_path"] if len(auth_path) == 0 else auth_path
integ_path = input(f'Enter integ path: ({helper.config["integ_path"]}): ')
integ_path = helper.config["integ_path"] if len(integ_path) == 0 else integ_path
app_sk = secrets.token_hex(16)
print(f"FLASK SECRET KEY: {app_sk}")
helper.config_write(host=host,port=port,code_name=code_name,auth_path=auth_path,integ_path=integ_path,sender_mail=email,sender_password=password,receiver_mail=receiver_mail,app_sk=app_sk)
except PermissionError:
print("Run as administrator")
quit()

print("Code Name: {}".format(auth.code_name))


def change_auth_key(old_key,new_key):
try:
change_key = Auth(old_key)
change_key.authenticate()
if change_key.isAuthenticated:
change_key.remove_auth()
new_key = Auth(new_key)
new_key.create_authkey()
print("[+] Auth key changed successfully")

ch = input("""
Warning: Sender's Email address and password are being stored in plain text.
Please do NOT use your personal email address and password instead user DUMMY email account.
I understand the risks and i am not using my personal information. (Y/N):
""")
if ch.lower() == "y":
email = input("Enter your email address: ")
password = getpass.getpass("Enter your password: ")
receiver_mail = input("Enter receiver email address: ")
app_sk = secrets.token_hex(16)
print(f"FLASK SECRET KEY: {app_sk}")
helper.config_write(sender_mail=email,sender_password=password,receiver_mail=receiver_mail,app_sk=app_sk)
print('Configuration Saved successfully...')
else:
print("Quiting...")
quit()
else:
print("[-] Authentication failed")
except PermissionError:
print("[-] Run as administrator")
quit()

def main():
menu = """
1: Change Auth Key
2: Delete Authentication
3: exit
"""
print(menu)
option = input("Choose Option:")
if option == "1":
old_key = getpass.getpass("old key: ")
new_key = getpass.getpass("new key: ")
change_auth_key(old_key,new_key)
elif option == "3":
exit()
elif option == "2":
key = getpass.getpass("Enter key: ")
delete_auth = Auth(key)
delete_auth.authenticate()
delete_auth.remove_auth()
print("Authentication removed successfully")
main()

Empty file added core/__init__.py
Empty file.
85 changes: 85 additions & 0 deletions core/auth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import hashlib
import pyAesCrypt
import os
from .misc import Misc

helper = Misc()

class Auth():

def __init__(self,authkey,code_name = helper.gethost()):
self.authkey = authkey
self.isAuthenticated = False
self.code_name = code_name
self.auth_path = helper.config_parser('auth_path')
self.integ_path = helper.config_parser('integ_path')
#self.filename = os.path.basename(self.auth_path)


def check_auth_integrity(self):
try:
pyAesCrypt.decryptFile(f'{self.integ_path}.lock', self.integ_path, self.authkey)
with open(self.integ_path, 'r') as stored_checksum:
content_stored_checksum = stored_checksum.read()
with open(self.auth_path, 'rb') as auth_checksum:
if str(hashlib.sha256(auth_checksum.read()).hexdigest()) == content_stored_checksum:
pyAesCrypt.encryptFile(self.integ_path,f"{self.integ_path}.lock",self.authkey)
return True
else:
pyAesCrypt.encryptFile(self.integ_path,f"{self.integ_path}.lock",self.authkey)
return False
except ValueError:
print("Authentication Failed!!!")
return None


def create_authkey(self):
integ = ''
with open(self.auth_path, 'w') as auth:
integ = hashlib.sha256(str(hashlib.sha256(self.authkey.encode()).hexdigest()).encode()).hexdigest()
auth.write(hashlib.sha256(self.authkey.encode()).hexdigest())
with open(self.integ_path,'w') as integ_write:
integ_write.write(integ)
pyAesCrypt.encryptFile(self.integ_path,f"{self.integ_path}.lock",self.authkey)
os.remove(self.integ_path)


def authenticate(self):
if self.check_auth_integrity():
with open(self.auth_path, 'r') as auth:
if str(hashlib.sha256(self.authkey.encode()).hexdigest()) == auth.read():
self.isAuthenticated = True

def is_first(self):
if os.path.exists(self.auth_path):
return False
return True

def remove_auth(self):
if self.isAuthenticated:
if os.path.exists(self.auth_path):
os.remove(self.auth_path)
if os.path.exists(self.integ_path):
os.remove(self.integ_path)
if os.path.exists(f'{self.integ_path}.lock'):
os.remove(f'{self.integ_path}.lock')
if os.path.exists('C:\\Windows\\System32\\6u4rd.mail'):
os.remove('C:\\Windows\\System32\\6u4rd.mail')
else:
print("Authentication failed")


def revoke_authentication(self):
self.isAuthenticated = False

def getcodename(self):
return helper.config_parser('code_name')









67 changes: 67 additions & 0 deletions core/c2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import os
import cv2
import pyautogui
import tempfile
import datetime
import ctypes
from PIL import ImageTk, Image
from .misc import Misc
from win32com import adsi
from win32security import LogonUser
from win32con import LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT
import pythoncom


helper = Misc()
class CommandAndControl():

def __init__(self):
self.client_private_ip = helper.getip()
self.client_hostname = helper.gethost()
self.temp_dir = tempfile.gettempdir()

def getss(self):
ss_name = f"pyc2ss{datetime.datetime.now().strftime('%Y%m%d%H%M%S')}.png"
ss_path = f"{self.temp_dir}\\{ss_name}"
pyautogui.screenshot(ss_path)


def getfrontcam(self): # Does not work at moment
webcam = cv2.VideoCapture(0)
check, frame = webcam.read()
img_name = f"pyc2webcam{datetime.datetime.now().strftime('%Y%m%d%H%M%S')}.png"
webp_path = f"{self.temp_dir}\\{img_name}"
cv2.imwrite(filename=webp_path, img=frame)
webcam.release()


def shutdown_client(self):
os.system("shutdown /s /f /t 0")

def lock_client(self):
lock = 0
while lock !=1:
lock = ctypes.windll.user32.LockWorkStation()


def switch_profile(self): # To Be Added in later versions
pass

def getscreen(self): # To Be Added in later versions
pass

def set_password(self,username, password):
try:
pythoncom.CoInitialize()
ads_obj = adsi.ADsGetObject(f"WinNT://localhost/{username},user")
ads_obj.Getinfo()
ads_obj.SetPassword(password)
except Exception as e:
print(f"Error: {e}")

def verify_success(self,username, password):
try:
LogonUser(username, None, password, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT)
except:
return False
return True
60 changes: 60 additions & 0 deletions core/mail.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from re import I
import smtplib, ssl
from email.message import EmailMessage
from core.misc import Misc


helper = Misc()
class Mailer():


def __init__(self):
self.email = None
self.password = None
self.context = ssl.create_default_context()
self.receiver = None
self.server = "smtp.gmail.com"
self.port = 465
self.ngrok_link = None
self.email_content = EmailMessage()


def sendmail(self):
try:
with smtplib.SMTP_SSL(self.server, self.port, context=self.context) as server:
server.login(self.email, self.password)
self.email_content['To'] = self.receiver
self.email_content['From'] = self.email
self.email_content['Subject'] = self.ngrok_link
self.email_content.set_content = self.ngrok_link
server.sendmail(self.email, self.receiver, self.email_content.as_string())
except Exception as e:
print(e)


def get_values(self):
try:
self.email = helper.config_parser('sender_mail')
self.password = helper.config_parser('sender_password')
self.receiver = helper.config_parser('receiver_mail')
except Exception as e:
print(e)


def get_ngrok_link(self, link):
self.ngrok_link = link


"""
def set_values(self, email, password, receiver):
try:
with open(self.config, 'w') as mail_config:
mail_config.write(email + "\n")
mail_config.write(password + "\n")
mail_config.write(receiver + "\n")
except Exception as e:
print(e)
"""


Loading

0 comments on commit 0d1be77

Please sign in to comment.