mirror of https://github.com/n1nj4sec/pupy.git
fix flake8 errors
This commit is contained in:
parent
cf623e3217
commit
e44cd7610b
|
@ -26,8 +26,11 @@ pip install venv
|
|||
python3 -m venv pupyvenv
|
||||
source pupyvenv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
|
||||
python3 -m pupy.cli.pupysh
|
||||
```
|
||||
run pupysh from the dev install :
|
||||
```
|
||||
source pupyenv/bin/activate
|
||||
python3 -m pupy.cli
|
||||
```
|
||||
|
||||
## Description
|
||||
|
|
|
@ -77,10 +77,7 @@ class PupyClient(object):
|
|||
# alias
|
||||
self.conn = self.desc['conn']
|
||||
|
||||
self.is3to2 = (
|
||||
self.conn.remote_version[0] == 2 and
|
||||
sys.version_info.major == 3
|
||||
)
|
||||
self.is3to2 = (self.conn.remote_version[0] == 2 and sys.version_info.major == 3)
|
||||
|
||||
self.target = dependencies.Target(
|
||||
self.conn.remote_version,
|
||||
|
|
|
@ -10,12 +10,10 @@ import getpass
|
|||
import uuid
|
||||
import sys
|
||||
import os
|
||||
import locale
|
||||
import logging
|
||||
import socket
|
||||
import pupy.agent as pupy
|
||||
|
||||
import encodings
|
||||
|
||||
|
||||
def _as_unicode(x):
|
||||
|
@ -448,12 +446,12 @@ def get_uuid():
|
|||
|
||||
try:
|
||||
uacLevel = getUACLevel()
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
uacLevel = "?"
|
||||
|
||||
try:
|
||||
integrity_level = get_integrity_level()
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
integrity_level = "?"
|
||||
|
||||
try:
|
||||
|
|
|
@ -59,7 +59,7 @@ from .PupyModule import (
|
|||
from .PupyCompleter import CompletionContext
|
||||
from .PupyVersion import BANNER, UPSTREAM, DISCLAIMER
|
||||
from .PupyOutput import (
|
||||
Text, Line, Color, Title, NewLine, Info,
|
||||
Line, Color, Title, NewLine, Info,
|
||||
ServiceInfo, Warn, Error, Success, Indent
|
||||
)
|
||||
|
||||
|
@ -538,7 +538,7 @@ class PupyCmd(cmd.Cmd):
|
|||
if cmd is None:
|
||||
return self.default(line)
|
||||
self.lastcmd = line
|
||||
if line == 'EOF' :
|
||||
if line == 'EOF':
|
||||
self.lastcmd = ''
|
||||
if cmd == '':
|
||||
return self.default(line)
|
||||
|
|
|
@ -166,9 +166,7 @@ def module_name_completer(module, args, text, context):
|
|||
clients_filter=context.handler.default_filter)
|
||||
)
|
||||
|
||||
return [
|
||||
module for module in modules if module.startswith(text) or not(text)
|
||||
]
|
||||
return [module for module in modules if module.startswith(text) or not text]
|
||||
|
||||
|
||||
def module_args_completer(module, args, text, context):
|
||||
|
|
|
@ -47,6 +47,7 @@ if sys.version_info.major > 2:
|
|||
from itertools import filterfalse
|
||||
|
||||
basestring = str
|
||||
long = int
|
||||
|
||||
else:
|
||||
from itertools import ifilterfalse as filterfalse
|
||||
|
|
|
@ -304,26 +304,14 @@ class PupyWebServer(object):
|
|||
|
||||
def get_random_path_at_webroot(self):
|
||||
while True:
|
||||
filename = ''.join(
|
||||
random.choice(
|
||||
string.ascii_uppercase +
|
||||
string.ascii_lowercase +
|
||||
string.digits
|
||||
) for _ in xrange(10)
|
||||
)
|
||||
filename = ''.join(random.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits) for _ in xrange(10))
|
||||
|
||||
filepath = path.join(self.root, filename)
|
||||
if not path.isfile(filepath):
|
||||
return filepath, filename
|
||||
|
||||
def random_path(self):
|
||||
return '/' + ''.join(
|
||||
random.choice(
|
||||
string.ascii_uppercase +
|
||||
string.ascii_lowercase +
|
||||
string.digits
|
||||
) for _ in xrange(10)
|
||||
)
|
||||
return '/' + ''.join(random.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits) for _ in xrange(10))
|
||||
|
||||
def register_mapping(self, name):
|
||||
name = self.random_path()
|
||||
|
|
|
@ -11,7 +11,6 @@ __all__ = [
|
|||
import os
|
||||
import sys
|
||||
import platform
|
||||
import re
|
||||
|
||||
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
||||
HOST_SYSTEM = platform.system()
|
||||
|
@ -49,4 +48,3 @@ if not getattr(sys, '__from_build_library_zip_compiler__', False):
|
|||
from .PupyModule import PupyModule
|
||||
from .PupyClient import PupyClient
|
||||
from .PupyServer import PupyServer
|
||||
|
||||
|
|
|
@ -359,8 +359,7 @@ def get_py_encoding(content):
|
|||
return
|
||||
|
||||
line = lines[0]
|
||||
if not (line.startswith(b'#') and
|
||||
b'coding:' in line):
|
||||
if not (line.startswith(b'#') and b'coding:' in line):
|
||||
return
|
||||
|
||||
idx = line.find(b'coding:') + 7
|
||||
|
@ -845,13 +844,13 @@ def add_missing_init(target, modules):
|
|||
f=pathname+"/__init__.pyo"
|
||||
if f not in modules and f not in toadd and f[:-1] not in modules:
|
||||
logger.debug("adding missing {}".format(f))
|
||||
toadd[f] = pupycompile("", pathname , target=target.pyver)
|
||||
toadd[f] = pupycompile("", pathname, target=target.pyver)
|
||||
modules.update(toadd)
|
||||
|
||||
def bundle(target):
|
||||
if not target.os or not target.arch:
|
||||
return None
|
||||
|
||||
|
||||
bundle_name = '{}-{}-{}{}.zip'.format(
|
||||
target.os, target.arch, target.pymaj, target.pymin
|
||||
)
|
||||
|
|
|
@ -5,7 +5,6 @@ from __future__ import print_function
|
|||
|
||||
import os
|
||||
import json
|
||||
import codecs
|
||||
|
||||
from pupy.network.lib.convcompat import (
|
||||
ExtendedJsonEncoder, ExtendedJsonDecoder,
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: UTF8 -*-
|
||||
|
||||
import requests
|
||||
import shutil
|
||||
import os
|
||||
from tqdm.auto import tqdm
|
||||
# make an HTTP request within a context manager
|
||||
with requests.get("https://www.example.com/file.txt", stream=True) as r:
|
||||
# check header to get content length, in bytes
|
||||
total_length = int(r.headers.get("Content-Length"))
|
||||
# implement progress bar via tqdm
|
||||
with tqdm.wrapattr(r.raw, "read", total=total_length, desc="")as raw:
|
||||
# save the output to a file
|
||||
with open(f"{os.path.basename(r.url)}", 'wb')as output:
|
||||
shutil.copyfileobj(raw, output)
|
|
@ -13,7 +13,6 @@ import struct
|
|||
import platform
|
||||
import re
|
||||
import locale
|
||||
import codecs
|
||||
|
||||
import fcntl
|
||||
import termios
|
||||
|
@ -660,10 +659,7 @@ def as_term_bytes(text, width=0):
|
|||
for line in hexdump.dumpgen(content):
|
||||
if text.colorize:
|
||||
# Change to something HexdumpLexer knows
|
||||
lines.append(
|
||||
line[:8] + ' ' + line[9:60] + '|' +
|
||||
line[60:] + '|'
|
||||
)
|
||||
lines.append(line[:8] + ' ' + line[9:60] + '|' + line[60:] + '|')
|
||||
else:
|
||||
lines.append(line)
|
||||
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
[flake8]
|
||||
# This style things should be fixed with time.
|
||||
# They should be ungnored one-by-one and fixed.
|
||||
|
||||
# E722 -- Should be fixed somehow
|
||||
|
||||
# W606 - Rpyc (at least old) incompatible with Python3.7
|
||||
|
||||
# !!! DO NOT ADD ANY NEW EXCEPTION HERE !!!
|
||||
|
||||
ignore = E722,
|
||||
E501,E402,
|
||||
E241,E221,E211,E222,E225,E226,E227,E272,E231,
|
||||
E251,E265,E302,E225,E305,E303,
|
||||
E228,E127,E128,E129,E502,E271,E261,E261,E262,
|
||||
E122,E123,E124,E125,E126,E131,E121,E226,E266,E242,
|
||||
E731,W606
|
||||
|
||||
|
||||
per-file-ignores =
|
||||
# X509 standard names are short
|
||||
pupylib/PupyCredentials.py: E741
|
||||
|
||||
# FIXME: add proper __all__ statement
|
||||
packages/windows/all/pupwinutils/hookfuncs.py: F401
|
||||
network/lib/__init__.py: F401
|
||||
network/lib/transports/cryptoutils/pyaes/__init__.py: F401
|
||||
|
||||
# Large stolen file
|
||||
packages/windows/all/wmi.py: E111
|
||||
|
||||
# Legacy formatting
|
||||
network/lib/transports/cryptoutils/pyaes/aes.py: E201,E202,E222,W504
|
||||
|
||||
# False positive
|
||||
packages/all/fsutils.py: F811
|
||||
|
||||
exclude =
|
||||
conf
|
||||
crypto
|
||||
data
|
||||
external
|
||||
library_patches
|
||||
output
|
||||
payload_templates
|
||||
proxy
|
||||
webstatic
|
||||
packages/patches
|
||||
# deprecated
|
||||
network/lib/streams/PupyAsyncStream.py
|
||||
# symlinks (travis workaround)
|
||||
packages/linux/all/lazagne
|
||||
packages/linux/all/mimipy.py
|
||||
packages/linux/all/beroot
|
||||
packages/windows/all/beroot
|
||||
packages/windows/all/lazagne
|
Loading…
Reference in New Issue