def certificates_gen(): logging.info("Downloading/extracting EasyRsa") cmd_list = [ [ "wget", "https://github.com/OpenVPN/easy-rsa/releases" + "/download/v3.0.8/EasyRSA-3.0.8.tgz", ], ["tar", "xvf", "EasyRSA-3.0.8.tgz"], ["cp", "EasyRSA-3.0.8/vars.example", "EasyRSA-3.0.8/vars"], ] [command(cmd) for cmd in cmd_list] # writing vars config file for easy rsa with open(exec_path + "/EasyRSA-3.0.8/vars", "a") as f: [f.write("\n" + option) for option in Config.RSA] logging.info("initialising Easy RSA") if not os.path.exists(exec_path + "/pki"): command(["EasyRSA-3.0.8/./easyrsa", "init-pki"]) # buiding CA certificate if not os.path.exists(exec_path + "/pki/ca.crt"): try: build_ca = Shell(has_input=True) build_ca.run("EasyRSA-3.0.8/./easyrsa build-ca nopass") build_ca.write("\n") logging.info("CA certificate generated") except CommandError as e: return [1, str(e)] # generating server certificate request + signing if not os.path.exists(exec_path + "/pki/reqs/server.req"): try: serv_certificate = Shell(has_input=True) serv_certificate.run( "EasyRSA-3.0.8/./easyrsa gen-req server nopass") serv_certificate.write("\n") logging.info("request for server cert generated") except CommandError as e: return [1, str(e)] try: sign_serv_cert = Shell(has_input=True) sign_serv_cert.run( "EasyRSA-3.0.8/./easyrsa sign-req server server") sign_serv_cert.write("yes\n") logging.info("server cert signed") except CommandError as e: return [1, str(e)] # generating Diffie Hellman Key + HMAC signature if not os.path.exists(exec_path + "/pki/dh.pem"): command(["sudo", exec_path + "/EasyRSA-3.0.8/./easyrsa", "gen-dh"]) if not os.path.exists(exec_path + "/ta.key"): command(["openvpn", "--genkey", "--secret", "ta.key"]), # moving the certs/keys into the openvpn dir cmd_list2 = [ ["sudo", "cp", exec_path + "/pki/private/server.key", "/etc/openvpn/"], ["sudo", "cp", exec_path + "/pki/issued/server.crt", "/etc/openvpn"], ["sudo", "cp", exec_path + "/pki/ca.crt", "/etc/openvpn"], ["sudo", "cp", exec_path + "/ta.key", "/etc/openvpn/"], ["sudo", "cp", exec_path + "/pki/dh.pem", "/etc/openvpn/"], ] [command(cmd) for cmd in cmd_list2] return [0, "changed"]
def shooting(self, shells): """ The method is responsible for the behavior of the projectile. """ if len(shells) < 10: if self.position: coordinates_shell = [round(self.x + 45), round(self.y + 22)] shell = Shell(coordinates_shell, 1) else: coordinates_shell = [round(self.x + 10), round(self.y + 22)] shell = Shell(coordinates_shell, -1) shells.append(shell) return shells
def test_initialization(self): sh = Shell() self.assertFalse(sh.has_input) self.assertTrue(sh.record_output) self.assertTrue(sh.record_errors) self.assertEqual(sh.last_command, '') self.assertEqual(sh.line_breaks, '\n') self.assertEqual(sh.code, 0) self.assertEqual(sh._popen, None) sh = Shell(has_input=True, record_output=False, record_errors=False) self.assertTrue(sh.has_input) self.assertFalse(sh.record_output) self.assertFalse(sh.record_errors)
def __init__(self, master=None, gamemgr=None, custommgr=None, inimgr=None, **kwargs): super().__init__(master=master, **kwargs) self.__master = master self.__gamemgr = Shell() if gamemgr is None else gamemgr self.__custommgr = ShellCustom() if custommgr is None else custommgr self.__ini_mgr = sh.IniManager( self.__custommgr) if inimgr is None else inimgr self.__menu = GUIMenuBar(self, self.__ini_mgr) self.__tabs = ttk.Notebook(master=self) self.__tab_vanilla = GUITabVanilla(self.__gamemgr, master=self.__tabs) self.__tab_vanilla.pack() self.__tab_custom = GUITabCustom(self.__custommgr, master=self.__tabs) self.__tab_custom.pack() self.__tabs.add(self.__tab_vanilla, text="Official Releases") self.__tabs.add(self.__tab_custom, text="Custom Game") self.__tabs.tab(0, sticky=tk.N + tk.S) self.__tabs.grid() self.winfo_toplevel().config(menu=self.__menu) self.update_all() self.__update_state_required = self.__menu.update_state_required self.__update_state_required.trace_add("write", self.update_all) self.pack()
def __init__(self, parent, filename=None): """Create EditorShellNotebook instance.""" wx.Notebook.__init__(self, parent, id=-1) usePanels = True if usePanels: editorparent = editorpanel = wx.Panel(self, -1) shellparent = shellpanel = wx.Panel(self, -1) else: editorparent = self shellparent = self self.buffer = Buffer() self.editor = Editor(parent=editorparent) self.buffer.addEditor(self.editor) self.buffer.open(filename) self.shell = Shell(parent=shellparent, locals=self.buffer.interp.locals, style=wx.CLIP_CHILDREN | wx.SUNKEN_BORDER) self.buffer.interp.locals.clear() if usePanels: self.AddPage(page=editorpanel, text='Editor', select=True) self.AddPage(page=shellpanel, text='Shell') # Setup sizers editorsizer = wx.BoxSizer(wx.VERTICAL) editorsizer.Add(self.editor.window, 1, wx.EXPAND) editorpanel.SetSizer(editorsizer) editorpanel.SetAutoLayout(True) shellsizer = wx.BoxSizer(wx.VERTICAL) shellsizer.Add(self.shell, 1, wx.EXPAND) shellpanel.SetSizer(shellsizer) shellpanel.SetAutoLayout(True) else: self.AddPage(page=self.editor.window, text='Editor', select=True) self.AddPage(page=self.shell, text='Shell') self.editor.setFocus() wx.EVT_NOTEBOOK_PAGE_CHANGED(self, self.GetId(), self.OnPageChanged)
def __init__(self, parent, id=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.SP_3D | wx.SP_LIVE_UPDATE, name='Crust Window', rootObject=None, rootLabel=None, rootIsNamespace=True, intro='', locals=None, InterpClass=None, startupScript=None, execStartupScript=True, *args, **kwds): """Create Crust instance.""" wx.SplitterWindow.__init__(self, parent, id, pos, size, style, name) self.shell = Shell(parent=self, introText=intro, locals=locals, InterpClass=InterpClass, startupScript=startupScript, execStartupScript=execStartupScript, *args, **kwds) self.editor = self.shell if rootObject is None: rootObject = self.shell.interp.locals self.notebook = wx.Notebook(parent=self, id=-1) self.shell.interp.locals['notebook'] = self.notebook self.filling = Filling(parent=self.notebook, rootObject=rootObject, rootLabel=rootLabel, rootIsNamespace=rootIsNamespace) # Add 'filling' to the interpreter's locals. self.shell.interp.locals['filling'] = self.filling self.notebook.AddPage(page=self.filling, text='Namespace', select=True) self.display = Display(parent=self.notebook) self.notebook.AddPage(page=self.display, text='Display') # Add 'pp' (pretty print) to the interpreter's locals. self.shell.interp.locals['pp'] = self.display.setItem self.display.nbTab = self.notebook.GetPageCount() - 1 self.calltip = Calltip(parent=self.notebook) self.notebook.AddPage(page=self.calltip, text='Calltip') self.sessionlisting = SessionListing(parent=self.notebook) self.notebook.AddPage(page=self.sessionlisting, text='History') self.dispatcherlisting = DispatcherListing(parent=self.notebook) self.notebook.AddPage(page=self.dispatcherlisting, text='Dispatcher') self.SplitHorizontally(self.shell, self.notebook, -self.sashoffset) self.SetMinimumPaneSize(100) self.Bind(wx.EVT_SIZE, self.SplitterOnSize) self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGED, self.OnChanged)
def test_chaining(self): sh = Shell(has_input=True) output = sh.run('cat -u').write('Hello, world!').output() self.assertEqual(output, ['Hello, world!']) output = shell('cat -u', has_input=True).write('Hello, world!').output() self.assertEqual(output, ['Hello, world!'])
def qstat(jid): """ Check job status """ s = Shell() rc, out, m = s.cmd1("qstat %s | grep %s | awk '{print $5}'" % (jid, jid)) if rc != 0: return None return out.strip('\n')
def test_worker_commands(self): context = Context() inbox = Queue() mouth = Queue() shell = Shell(context, inbox, mouth) worker_commands = [ ('deploy', shell.do_deploy), ('dispose', shell.do_dispose), ('information', shell.do_information), ('prepare', shell.do_prepare), ('refresh', shell.do_refresh), ('start', shell.do_start), ('stop', shell.do_stop), ] for label, do in worker_commands: do('123') context.set('worker.busy', True) do('456') context.set('worker.busy', False) do('789') self.assertEqual(mouth.get(), "Ok, working on it") self.assertEqual(mouth.get(), "Ok, will work on it as soon as possible") self.assertEqual(mouth.get(), "Ok, working on it") with self.assertRaises(Exception): mouth.get_nowait() self.assertEqual(inbox.get(), (label, '123')) self.assertEqual(inbox.get(), (label, '456')) self.assertEqual(inbox.get(), (label, '789')) with self.assertRaises(Exception): inbox.get_nowait()
def checkCanFire(self): if self.power > 90: if self.tank.mag < 400: shell = Shell(self.Screen, (self.x, self.y), self.dir, self.preyTank, self.score) self.allSprites.add(shell) self.power = 0
def handle_keys(self, keys): if keys[self._key_map['l']]: self._a += self._va self.vx_vy_update() elif keys[self._key_map['r']]: self._a -= self._va self.vx_vy_update() if keys[self._key_map['u']]: self._x += self._vx self._y -= self._vy elif keys[self._key_map['d']]: self._x -= self._vx self._y += self._vy if keys[self._key_map['s']]: shell = Shell(self._x, self._y, self._vx * 3, self._vy * 3, self) self._scene.add_actor(shell) rect = self._surf2.get_rect() w = rect.width / 2 h = rect.height / 2 self._x = min(self._x, self._game.width - w - 2) self._x = max(self._x, 0 + w + 2) self._y = min(self._y, self._game.height - h - 2) self._y = max(self._y, 0 + h + 2)
def test_do_parameters(self): context = Context() inbox = Queue() mouth = Queue() shell = Shell(context, inbox, mouth) context.set('plumbery.fittings', os.path.dirname(os.path.realpath(__file__))) context.set('worker.template', 'category1/fittings1') shell.do_parameters() self.assertEqual(mouth.get(), "Available parameters:") self.assertEqual(mouth.get(), "- cpuPerNode: 4") self.assertEqual(mouth.get(), "- diskPerNode: 200") self.assertEqual(mouth.get(), "- domainName: HadoopClusterFox") self.assertEqual(mouth.get(), "- locationId: EU6") self.assertEqual(mouth.get(), "- memoryPerNode: 12") self.assertEqual(mouth.get(), "- networkName: HadoopClusterNetwork") with self.assertRaises(Exception): mouth.get_nowait() with self.assertRaises(Exception): inbox.get_nowait() shell.do_parameters('category1/fittings2') self.assertEqual(mouth.get(), "No parameter for category1/fittings2") with self.assertRaises(Exception): mouth.get_nowait() with self.assertRaises(Exception): inbox.get_nowait()
def __init__(self, shell=None, logDirectory=None): """The Compiler is a wrapper for the three compiler components.""" self.shell = shell if shell else Shell() self.logDirectory = logDirectory # Make a cache for loading files. self.cache = {}
def dead(self, map_group=None, enemy_group=None, fireball_group=None): self.settings.score_holder += self.settings.point_values['koopa'] self.is_dead = True # if map_group and enemy_group and fireball_group: if map_group != None and enemy_group != None and fireball_group != None: s = Shell(self.screen, self.settings, self.rect.centerx, self.rect.centery) s.add(map_group, enemy_group, fireball_group)
def do_fire(self, objects): if self.fire_dt > 1000000 / self.FIRE_RATE: shell = Shell(-self.move_v * self.SPEED) shell.scale_factor = 1.75 shell.setSprite(self.shell_texture) shell.sprite.position = self.sprite.position objects.append(shell) self.fire_dt = 0
def test__handle_output_norecord(self): sh = Shell(record_output=False, record_errors=False) self.assertEqual(sh._stdout, '') self.assertEqual(sh._stderr, '') sh._handle_output('another.txt\n', 'Error: Please supply an arg.') self.assertEqual(sh._stdout, '') self.assertEqual(sh._stderr, '')
def setUp(self): super(ShellTestCase, self).setUp() self.test_dir = os.path.join('/tmp', 'python_shell') self.hello_path = os.path.join(self.test_dir, 'hello.txt') self.sh = Shell() shutil.rmtree(self.test_dir, ignore_errors=True) os.makedirs(self.test_dir)
def test_verbose(self): sh = Shell(verbose=True) with mock.patch('shell.sys.stdout') as mock_stdout: sh.run('ls') mock_stdout.write.assert_called_once_with(os.linesep.join(sh.output()) + os.linesep) with mock.patch('shell.sys.stderr') as mock_stderr: sh.run('ls /total/garbage/not/real/stuff') mock_stderr.write.assert_called_once_with(os.linesep.join(sh.errors()) + os.linesep)
def main(): try: shell = Shell() if "-sub" in argv: run_subshell(shell, argv) else: run(shell) except TypeError: return
def test_die(self): sh = Shell(die=True) with self.assertRaises(CommandError): sh.run('ls /maybe/this/exists/on/windows/or/something/idk') try: no_die = shell('ls /other/fake/stuff/for/sure') # get the stderr sh.run('ls /other/fake/stuff/for/sure') except CommandError, e: self.assertEqual(e.code, 1) self.assertEqual(e.stderr, no_die.errors()[0] + os.linesep)
def _add_shell_panel(self): """ Adds a python shell to the bottom pane. """ logger.debug("Adding shell.") self._shell = Shell() self._shell.set_font(self._font) panel = self.window.get_bottom_panel() panel.add_item_with_stock_icon(self._shell, "DjangoShell", "Python Shell", STOCK_PYTHON) self._setup_shell_panel() panel.activate_item(self._shell)
def _add_dbshell_panel(self): """ Adds a database shell to the bottom pane. """ logger.debug("Adding database shell panel.") self._dbshell = Shell() self._dbshell.set_font(self._font) panel = self.window.get_bottom_panel() panel.add_item_with_stock_icon(self._dbshell, "DjangoDbShell", "Database Shell", STOCK_DBSHELL) self._setup_dbshell_panel() panel.activate_item(self._dbshell)
def test_setenv(): os.environ['LOADEDMODULES'] = '' os.environ['_LMFILES_'] = '' shell = Shell('bash') modulename = 'setenv' filename = os.path.join(D, 'modulefiles', modulename + '.py') module_loader('load', modulename, shell) assert shell.variables['SALAMI'] == '/opt/1' assert shell.variables['LOADEDMODULES'] == modulename assert shell.variables['_LMFILES_'] == filename
def __init__(self, devdir, startsemlex, catroles): self.devdir = devdir self.allpatterns = { } #extract|case|trigger|triggertype as key, value is [freq of pattern, [extracts, heads]] self.bestpatterns = [ ] #A simple list containing the idkeys of best patterns for lookup in self.allpatterns. self.semlex = startsemlex #names of semantic categories are keys, lists of pairs words in each category and their heads are values self.catroles = catroles #names of semantic categories are keys, the semantic role of each category is the value self.shell = Shell() self.data = Data()
def handle_joystick(self, j): if j.joy != self._joy: return print(f'J-EVENT: {j}') if hasattr(j, 'button') and j.button == 5: shell = Shell(self._x, self._y, self._vx * 3, self._vy * 3, self) self._scene.add_actor(shell) pass
def __init__(self, parent, id=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.SP_3D|wx.SP_LIVE_UPDATE, name='Crust Window', rootObject=None, rootLabel=None, rootIsNamespace=True, intro='', locals=None, InterpClass=None, startupScript=None, execStartupScript=True, *args, **kwds): """Create Crust instance.""" wx.SplitterWindow.__init__(self, parent, id, pos, size, style, name) # Turn off the tab-traversal style that is automatically # turned on by wx.SplitterWindow. We do this because on # Windows the event for Ctrl-Enter is stolen and used as a # navigation key, but the Shell window uses it to insert lines. style = self.GetWindowStyle() self.SetWindowStyle(style & ~wx.TAB_TRAVERSAL) self.shell = Shell(parent=self, introText=intro, locals=locals, InterpClass=InterpClass, startupScript=startupScript, execStartupScript=execStartupScript, *args, **kwds) self.editor = self.shell if rootObject is None: rootObject = self.shell.interp.locals self.notebook = wx.Notebook(parent=self, id=-1) self.shell.interp.locals['notebook'] = self.notebook self.filling = Filling(parent=self.notebook, rootObject=rootObject, rootLabel=rootLabel, rootIsNamespace=rootIsNamespace) # Add 'filling' to the interpreter's locals. self.shell.interp.locals['filling'] = self.filling self.notebook.AddPage(page=self.filling, text='Namespace', select=True) self.display = Display(parent=self.notebook) self.notebook.AddPage(page=self.display, text='Display') # Add 'pp' (pretty print) to the interpreter's locals. self.shell.interp.locals['pp'] = self.display.setItem self.display.nbTab = self.notebook.GetPageCount()-1 self.calltip = Calltip(parent=self.notebook) self.notebook.AddPage(page=self.calltip, text='Calltip') self.sessionlisting = SessionListing(parent=self.notebook) self.notebook.AddPage(page=self.sessionlisting, text='History') self.dispatcherlisting = DispatcherListing(parent=self.notebook) self.notebook.AddPage(page=self.dispatcherlisting, text='Dispatcher') self.SplitHorizontally(self.shell, self.notebook, -self.sashoffset) self.SetMinimumPaneSize(100) self.Bind(wx.EVT_SIZE, self.SplitterOnSize) self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGED, self.OnChanged)
def main(): global _username, _domain, _classes, prevId init() print(Fore.WHITE + Style.BRIGHT + printBanner(), end='') with open(baseWritePath + prevId, 'r') as f: first = json.load(f) nextId = ''.join( random.choice(string.ascii_uppercase + string.digits) for _ in range(10)) first['NextId'] = nextId with open(baseWritePath + prevId, 'w') as f: json.dump(first, f) prevId = nextId content = waitAndReadFile(baseReadPath + prevId) print("[+] Connection successfully established!") time.sleep(3) print("[+] Patching ETW...") time.sleep(7) print("[+] Manually loading kernel32.dll to avoid API hooks.") time.sleep(7) print("[+] Manually loading advapi32.dll to avoid API hooks.") time.sleep(5) print("[+] Patching AMSI...") time.sleep(5) print("[+] H4ck th3 Pl4n3t!") userAndDomain = content['Output'] userAndDomain = userAndDomain.split("\\") _domain = userAndDomain[0] _username = userAndDomain[1] _classes.append(Download()) _classes.append(Base64encode()) _classes.append(Base64decode()) _classes.append(Compile()) _classes.append(Inject()) _classes.append(Powershell()) _classes.append(Send()) _classes.append(Impersonate()) _classes.append(Exfiltrate()) _classes.append(Runas()) _classes.append(Shell()) mainConsole() deinit()
def __init__(self): super().__init__() self.__gamemgr = Shell() self.__custommgr = ShellCustom() self.__ini_mgr = sh.IniManager(self.__custommgr) self.__ini_mgr.load() self.__gui = GUI( gamemgr=self.__gamemgr, custommgr=self.__custommgr, inimgr=self.__ini_mgr, master=self ) self.protocol("WM_DELETE_WINDOW", self.__quit) center(self)
def __init__(self, use_dummy=False, filename=None, **kwargs): super(TestRoot, self).__init__(**kwargs) self.use_dummy = use_dummy self.filename = filename self.resetting = False self.shell = Shell() self.shell.bind(on_stdout=self.on_stdout) self.shell.bind(on_stderr=self.on_stderr) self.shell.bind(on_exit=self.on_exit) self.ids.quit.bind(on_press=lambda x: self.stop()) self.ids.scan.bind(state=self.on_state_scan)
def __init__(self): self.commands = [ AddUser(), LogIn(), WhoIAm(), RemoveUser(), SetAsAdmin(), Users(), ChangePassword() ] self.running = True self.shell = Shell.Shell("admin", "admin")