Skip to content

Commit

Permalink
flake: fix various errors
Browse files Browse the repository at this point in the history
  • Loading branch information
alxchk committed Jun 1, 2020
1 parent c336ea7 commit 94fa1c1
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 36 deletions.
7 changes: 0 additions & 7 deletions create-workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,10 @@
import os
import sys
import errno
import tempfile
import tarfile
import hashlib
import shutil
import resource

if sys.version_info.major == 3:
from urllib.request import urlopen
else:
from urllib2 import urlopen

ENV_IMAGE = 'pupy-python2-env'
ENV_CONTAINER = 'pupy-'

Expand Down
2 changes: 1 addition & 1 deletion pupy/modules/exploit_suggester.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def run(self, args):

proposed.add(exploit)

impact = ''.join(l[0] for l in res['Impact'].split())
impact = ''.join(part[0] for part in res['Impact'].split())
color = 'white'
if impact == 'ID':
color = 'grey'
Expand Down
4 changes: 3 additions & 1 deletion pupy/modules/outlook.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ def run(self, args):
self.success("Trying to download Outlook OST file of the targeted current user")
paths = outlook.getPathToOSTFiles()
if len(paths)>0:
localPath = os.path.join(self.localFolder, ''.join(l for l in paths[0][0].encode('ascii','ignore') if l.isalnum()))
localPath = os.path.join(self.localFolder, ''.join(
path for path in paths[0][0].encode('ascii', 'ignore') if path.isalnum())
)
self.success("Downloading the file {0} to {1}...".format(paths[0][1], localPath))
download(self.client.conn, paths[0][1], localPath)
self.success("OST file downloaded from {0} to {1}".format(paths[0][1], localPath))
Expand Down
2 changes: 1 addition & 1 deletion pupy/network/lib/picocmd/dns_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def __lt__(self, other):
return self.weight < other.weight

def __repr__(self):
return '{{R:{}}}'.format(self.weight, self.A, self.B)
return '{{R:({}) ({}) ({})}}'.format(self.weight, self.A, self.B)


class Huffman(object):
Expand Down
3 changes: 3 additions & 0 deletions pupy/network/lib/picocmd/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1249,6 +1249,9 @@ def process(self, qtype, qname):

return None

except UnknownVersion:
return None

except Exception as e:
logger.exception(e)

Expand Down
4 changes: 2 additions & 2 deletions pupy/packages/all/cloudinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ def valueconv(x):
pass

try:
for l in x:
if l in string.letters:
for letter in x:
if letter in string.letters:
base64.b64decode(x)
return x
except:
Expand Down
4 changes: 3 additions & 1 deletion pupy/packages/all/pupyutils/smbspider.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ def search_string(self, path):
for string in self.search_str:
indexes = [m.start() for m in re.finditer(string, buffer, flags=re.IGNORECASE)]
for i in indexes:
r = "{path} > {content}".format(share=self.share, path=path, content=buffer[i:].strip().split('\n')[0])
r = "{share} {path} > {content}".format(
share=self.share, path=path, content=buffer[i:].strip().split('\n')[0]
)
yield r

rfile.close()
Expand Down
8 changes: 4 additions & 4 deletions pupy/packages/windows/all/outlook.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,17 @@ def getInformation(self):
info['ExchangeMailboxServerName']=self.mapi.ExchangeMailboxServerName #Returns a String value that represents the name of the Exchange server that hosts the primary Exchange account mailbox.
except Exception,e:
logging.debug("Impossible to get ExchangeMailboxServerName configuration: {0}".format(e))
info['ExchangeMailboxServerName'.format(i)]=""
info['ExchangeMailboxServerName']=""
try:
info['ExchangeMailboxServerVersion']=self.mapi.ExchangeMailboxServerVersion #Returns a String value that represents the full version number of the Exchange server that hosts the primary Exchange account mailbox.
except Exception,e:
logging.debug("Impossible to get ExchangeMailboxServerVersion configuration: {0}".format(e))
info['ExchangeMailboxServerVersion'.format(i)]=""
info['ExchangeMailboxServerVersion']=""
try:
info['Offline']=self.mapi.Offline #Returns a Boolean indicating True if Outlook is offline (not connected to an Exchange server), and False if online (connected to an Exchange server)
except Exception,e:
logging.debug("Impossible to get Offline configuration: {0}".format(e))
info['Offline'.format(i)]=""
info['Offline']=""
try:
info['ExchangeConnectionMode']=self.OL_EXCHANGE_CONNECTION_MODE[self.mapi.ExchangeConnectionMode]
self.mapi.SendAndReceive(True)
Expand Down Expand Up @@ -190,7 +190,7 @@ def getAMailFile(self, mailItem):
'''
ctime, subjectCleaned, receivedTime, path, filename = str(time.time()).replace('.',''), "Unknown", "Unknown", "", ""
try:
subjectCleaned = ''.join(l for l in mailItem.Subject.encode('ascii','ignore') if l.isalnum())
subjectCleaned = ''.join(subj for subj in mailItem.Subject.encode('ascii','ignore') if subj.isalnum())
receivedTime = str(mailItem.ReceivedTime).replace('/','').replace('\\','').replace(':','-').replace(' ','_')
except Exception,e:
logging.warning("Impossible to encode email subject or receivedTime:{0}".format(repr(e)))
Expand Down
16 changes: 14 additions & 2 deletions pupy/packages/windows/all/pupwinutils/hookfuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from ctypes import (
byref, WinDLL, WinError, sizeof, pointer,
c_int, c_ulong, c_void_p, c_wchar_p,
c_int, c_ulong, c_void_p, c_wchar_p, c_uint,
CFUNCTYPE, cast,
c_void_p as LPRECT,
c_void_p as PSID,
Expand All @@ -18,12 +18,24 @@

from ctypes.wintypes import (
BOOL, DOUBLE, DWORD, HBITMAP, HINSTANCE, HDC, HGDIOBJ, HANDLE,
HWND, INT, LPARAM, LONG, RECT, UINT, WORD, MSG, HMODULE, HHOOK,
HWND, INT, LPARAM, LONG, RECT, UINT, WORD, HMODULE, HHOOK, POINT,
LPCWSTR, WPARAM, LPVOID, LPSTR, LPWSTR, BYTE, WCHAR, SHORT,
WPARAM as ULONG_PTR,
LPARAM as LRESULT,
)

class MSG(Structure):
_fields_ = [
("hWnd", HWND),
("message", c_uint),
("wParam", WPARAM),
("lParam", LPARAM),
("time", DWORD),
("pt", POINT),
("private", DWORD)
]


# consts
WH_MOUSE_LL = 14
WM_MOUSEFIRST = 0x0200
Expand Down
2 changes: 1 addition & 1 deletion pupy/pupygen.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def generate_binary_from_template(display, config, osname, arch=None, shared=Fal
osname = osname.lower()

if osname not in CLIENTS.keys():
raise ValueError('Unknown OS ({}), known = '.format(
raise ValueError('Unknown OS ({}), known = {}'.format(
osname, ', '.join(CLIENTS.keys())))

generator, template, makex = CLIENTS[osname]
Expand Down
14 changes: 12 additions & 2 deletions pupy/pupylib/PupyCompleter.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from .PupyErrors import PupyModuleExit, PupyModuleUsageError
from .payloads.dependencies import paths


def package_completer(module, args, text, context):
clients = context.server.get_clients(context.handler.default_filter)

Expand Down Expand Up @@ -61,6 +62,7 @@ def package_completer(module, args, text, context):

return list(completions)


def commands_completer(module, args, text, context):
aliases = dict(context.config.items('aliases'))
modules = list(context.server.iter_modules(
Expand All @@ -76,14 +78,17 @@ def commands_completer(module, args, text, context):
x.get_name()+' ' for x in modules if x.get_name().startswith(text)
]

def list_completer(l):

def list_completer(lines):
def func(module, args, text, context):
return [x+" " for x in l if x.startswith(text)]
return [line+" " for line in lines if line.startswith(text)]
return func


def void_completer(module, args, text, context):
return []


def remote_path_completer(module, args, text, context, dirs=None):
results = []
try:
Expand All @@ -110,12 +115,15 @@ def remote_path_completer(module, args, text, context, dirs=None):

return results


def remote_dirs_completer(module, args, text, context):
return remote_path_completer(module, args, text, context, dirs=True)


def remote_files_completer(module, args, text, context):
return remote_path_completer(module, args, text, context, dirs=False)


def path_completer(module, args, text, context):
completions=[]

Expand All @@ -138,6 +146,7 @@ def path_completer(module, args, text, context):

return completions


def module_name_completer(module, args, text, context):

del module
Expand All @@ -152,6 +161,7 @@ def module_name_completer(module, args, text, context):
module for module in modules if module.startswith(text) or not(text)
]


def module_args_completer(module, args, text, context):
try:
args = module.arguments
Expand Down
7 changes: 4 additions & 3 deletions pupy/pupylib/PupyDnsCnc.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,10 @@ def connect(self, host, port, transport, hostname=None, node=None, default=False
raise ValueError('Listener for transport {} not found'.format(transport))

else:
for l in listeners.itervalues():
if not l.local or (port and (l.port == port or l.external_port == port)):
listener = l
for candidate in listeners.itervalues():
if not candidate.local or (port and (
candidate.port == port or candidate.external_port == port)):
listener = candidate
break

if not listener:
Expand Down
8 changes: 4 additions & 4 deletions pupy/pupylib/PupyModule.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,10 +550,10 @@ def closeio(self):


def config(**kwargs):
for l in ['compat', 'compatibilities', 'compatibility', 'tags']:
if l in kwargs:
if type(kwargs[l])!=list:
kwargs[l]=[kwargs[l]]
for option in ['compat', 'compatibilities', 'compatibility', 'tags']:
if option in kwargs:
if type(kwargs[option]) != list:
kwargs[option] = [kwargs[option]]

def class_rebuilder(klass):
klass.tags = kwargs.get('tags', klass.tags)
Expand Down
14 changes: 7 additions & 7 deletions pupy/pupylib/utils/term.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@

from pygments import highlight

TERM = os.environ.get('TERM')
if TERM and TERM.endswith('256color'):
from pygments.formatters import Terminal256Formatter as TerminalFormatter
else:
from pygments.formatters import TerminalFormatter

from pupylib.PupyOutput import (
Hint, Text, NewLine, Title, MultiPart, Indent, Color,
TruncateToTerm, Error, Log, Warn, Success, Info,
ServiceInfo, Section, Line, List, Table, Pygment
)

PYGMENTS_STYLE='native'
TERM = os.environ.get('TERM')
if TERM and TERM.endswith('256color'):
from pygments.formatters import Terminal256Formatter as TerminalFormatter
else:
from pygments.formatters import TerminalFormatter

PYGMENTS_STYLE = 'native'

ESC_REGEX = re.compile(r'(\033[^m]+m)')

Expand Down

0 comments on commit 94fa1c1

Please sign in to comment.