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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sys, os, subprocess, time
|
| 2 |
+
sys.path.insert(0, r"D:\0projects\bountykimi\tmp")
|
| 3 |
+
from harness import Call, build, check_stream, ART, MARKDIR, run_modelscan, clean_markers
|
| 4 |
+
|
| 5 |
+
cands = []
|
| 6 |
+
|
| 7 |
+
# B1: zipfile.ZipFile(mode='w') overwrite-existing = TRUNCATE/DELETE+CREATE (HIGH)
|
| 8 |
+
cands.append(("B1_zipfile_trunc", [
|
| 9 |
+
Call("zipfile", "ZipFile", os.path.join(MARKDIR, "b1_target_PWN.zip"), "w"),
|
| 10 |
+
]))
|
| 11 |
+
|
| 12 |
+
# B2: tarfile.TarFile(mode='w') truncation? tarfile.TarFile already in dupes. But truncation angle = overwrite. skip, listed.
|
| 13 |
+
|
| 14 |
+
# B3: open via io.open existing file mode 'w' truncates -> io.open done (generic). skip.
|
| 15 |
+
|
| 16 |
+
# B4: fileinput with inplace? destructive edit done? fileinput done. skip.
|
| 17 |
+
|
| 18 |
+
# B5: shelve writeback destructive? shelve done.
|
| 19 |
+
|
| 20 |
+
# B6: dbm.open existing file 'w' truncates -> dbm done.
|
| 21 |
+
|
| 22 |
+
# B7: logging.FileHandler mode 'w' truncation? FileHandler done.
|
| 23 |
+
|
| 24 |
+
# B8: bz2.BZ2File? bz2.open done.
|
| 25 |
+
|
| 26 |
+
# B9: xml.etree include? skip.
|
| 27 |
+
|
| 28 |
+
# B10: http.server.ThreadingHTTPServer bind (distinct class from HTTPServer, listen)
|
| 29 |
+
cands.append(("B10_threadinghttpserver", [
|
| 30 |
+
Call("http.server", "ThreadingHTTPServer", ("127.0.0.1", 18993), Call("http.server", "SimpleHTTPRequestHandler")),
|
| 31 |
+
]))
|
| 32 |
+
|
| 33 |
+
# B11: socketserver.UDPServer bind (UDP listen - distinct from TCPServer h7)
|
| 34 |
+
cands.append(("B11_udpserver_bind", [
|
| 35 |
+
Call("socketserver", "UDPServer", ("127.0.0.1", 18994), Call("socketserver", "DatagramRequestHandler")),
|
| 36 |
+
]))
|
| 37 |
+
|
| 38 |
+
# B12: http.server.ThreadingHTTPServer with CGIHTTPRequestHandler? CGI handler is cgi-exec capable but only on request. skip.
|
| 39 |
+
|
| 40 |
+
# B13: tempfile.SpooledTemporaryFile? in-memory then disk; TemporaryFile done A16. skip.
|
| 41 |
+
|
| 42 |
+
# B14: numpy.memmap fixed - file CREATE via memmap mode w+
|
| 43 |
+
cands.append(("B14_numpy_memmap", [
|
| 44 |
+
Call("numpy", "memmap", os.path.join(MARKDIR, "b14mm_PWN.bin"), "float32", "w+", 0, (10,)),
|
| 45 |
+
]))
|
| 46 |
+
|
| 47 |
+
# B15: mmap.mmap requires fd. skip.
|
| 48 |
+
|
| 49 |
+
# B16: csv.DictWriter builds writer only. skip.
|
| 50 |
+
|
| 51 |
+
# B17: zipfile.PyZipFile write mode (create pyz) distinct from ZipFile? Marginal. skip.
|
| 52 |
+
|
| 53 |
+
# B18: zipapp done.
|
| 54 |
+
|
| 55 |
+
# B19: compileall done.
|
| 56 |
+
|
| 57 |
+
# B20: py_compile done.
|
| 58 |
+
|
| 59 |
+
# B21: configparser write needs fp. configparser already has PWN from earlier (configparser_PWN.ini exists) but is it in dupes? Not listed! configparser.RawConfigParser().write needs fp. How was it done? Probably .read? Whatever - configparser.ConfigParser().read(path) = file READ (MEDIUM, distinct class).
|
| 60 |
+
cands.append(("B21_configparser_read", [
|
| 61 |
+
Call("configparser", "ConfigParser"),
|
| 62 |
+
]))
|
| 63 |
+
# .read is method. skip B21.
|
| 64 |
+
|
| 65 |
+
# B22: fileinput.input(inplace=1) destructive in-place edit of existing file (HIGH delete/write, distinct from fileinput read?)
|
| 66 |
+
# fileinput.input(files, inplace=True) -> on iteration writes. Iteration doesn't happen on load. skip.
|
| 67 |
+
|
| 68 |
+
# B23: linecache done.
|
| 69 |
+
|
| 70 |
+
# B24: getpass? no.
|
| 71 |
+
|
| 72 |
+
# B25: cgitb? no.
|
| 73 |
+
|
| 74 |
+
# B26: traceback done.
|
| 75 |
+
|
| 76 |
+
# B27: code module done.
|
| 77 |
+
|
| 78 |
+
# B28: pydoc done.
|
| 79 |
+
|
| 80 |
+
# B29: turtle? no.
|
| 81 |
+
|
| 82 |
+
# B30: uuid? no.
|
| 83 |
+
|
| 84 |
+
# B31: ipaddress? no.
|
| 85 |
+
|
| 86 |
+
# B32: sched? done (evil_sched). skip.
|
| 87 |
+
|
| 88 |
+
# B33: queue? no.
|
| 89 |
+
|
| 90 |
+
# B34: secrets? no.
|
| 91 |
+
|
| 92 |
+
# B35: stat? no.
|
| 93 |
+
|
| 94 |
+
# B36: fnmatch? no.
|
| 95 |
+
|
| 96 |
+
# B37: glob? read-only listing. glob.glob path - read dir listing (LOW). skip.
|
| 97 |
+
|
| 98 |
+
# B38: tempfile done enough.
|
| 99 |
+
|
| 100 |
+
# B39: signal? no.
|
| 101 |
+
|
| 102 |
+
# B40: resource? unix.
|
| 103 |
+
|
| 104 |
+
# B41: syslog? unix.
|
| 105 |
+
|
| 106 |
+
# B42: xmlrpc.server done h7.
|
| 107 |
+
|
| 108 |
+
# B43: xml.sax done. xml.dom.minidom.parse read (MEDIUM) distinct from sax?
|
| 109 |
+
cands.append(("B43_minidom_parse", [
|
| 110 |
+
Call("xml.dom.minidom", "parse", os.path.join(MARKDIR, "b43.xml")),
|
| 111 |
+
]))
|
| 112 |
+
|
| 113 |
+
# B44: xml.etree.ElementTree.parse read (MEDIUM)
|
| 114 |
+
cands.append(("B44_etree_parse", [
|
| 115 |
+
Call("xml.etree.ElementTree", "parse", os.path.join(MARKDIR, "b44.xml")),
|
| 116 |
+
]))
|
| 117 |
+
|
| 118 |
+
# B45: plistlib.load read (MEDIUM) - plistlib.dump done; load is read distinct
|
| 119 |
+
cands.append(("B45_plistlib_load", [
|
| 120 |
+
Call("plistlib", "load", Call("io", "open", os.path.join(MARKDIR, "b45.plist"), "rb")),
|
| 121 |
+
]))
|
| 122 |
+
|
| 123 |
+
# B46: json.load read (MEDIUM) via io.open
|
| 124 |
+
cands.append(("B46_json_load", [
|
| 125 |
+
Call("json", "load", Call("io", "open", os.path.join(MARKDIR, "b46.json"), "r")),
|
| 126 |
+
]))
|
| 127 |
+
|
| 128 |
+
# B47: marshal.load read (MEDIUM) via io.open
|
| 129 |
+
cands.append(("B47_marshal_load", [
|
| 130 |
+
Call("marshal", "load", Call("io", "open", os.path.join(MARKDIR, "b47.bin"), "rb")),
|
| 131 |
+
]))
|
| 132 |
+
|
| 133 |
+
# B48: csv.reader read via io.open (MEDIUM) - builds reader only, no read. skip.
|
| 134 |
+
|
| 135 |
+
# B49: filecmp done.
|
| 136 |
+
|
| 137 |
+
# B50: hmac? no.
|
| 138 |
+
|
| 139 |
+
# B51: sqlite3 executescript done (evil_sqliteexec). skip.
|
| 140 |
+
|
| 141 |
+
# B52: numpy.fromregex? read MEDIUM meh. skip.
|
| 142 |
+
|
| 143 |
+
# B53: array.array('i').fromfile method. skip.
|
| 144 |
+
|
| 145 |
+
# B54: pprint done.
|
| 146 |
+
|
| 147 |
+
# B55: reprlib? no.
|
| 148 |
+
|
| 149 |
+
# B56: dis? no.
|
| 150 |
+
|
| 151 |
+
# B57: pickletools? pickletools.dis reads pickle file arg? pickletools.dis(pickle_bytes) in-memory. skip.
|
| 152 |
+
|
| 153 |
+
# B58: doctest done.
|
| 154 |
+
|
| 155 |
+
# B59: unittest discover done.
|
| 156 |
+
|
| 157 |
+
# B60: importlib.machinery.SourceFileLoader.load_module? execs py file = RCE but load_module is method. SourceFileLoader(name, path) ctor then needs method. skip.
|
| 158 |
+
|
| 159 |
+
# B61: runpy blocked.
|
| 160 |
+
|
| 161 |
+
# B62: modulefinder done f62.
|
| 162 |
+
|
| 163 |
+
# B63: setuptools done.
|
| 164 |
+
|
| 165 |
+
# B64: pip done.
|
| 166 |
+
|
| 167 |
+
# B65: ensurepip.bootsstrap? ensurepip._main() installs pip -> writes files/exec? ensurepip.bootstrap() module-level, installs pip into env = file write. Marginal, slow. skip.
|
| 168 |
+
|
| 169 |
+
# B66: venv done.
|
| 170 |
+
|
| 171 |
+
# B67: site? no.
|
| 172 |
+
|
| 173 |
+
# B68: webbrowser blocked.
|
| 174 |
+
|
| 175 |
+
# B69: antigravity imports webbrowser -> blocked? antigravity module-level GLOBAL 'antigravity this'? evil_antigravity done earlier. skip.
|
| 176 |
+
|
| 177 |
+
# B70: this? no.
|
| 178 |
+
|
| 179 |
+
results = {}
|
| 180 |
+
for name, steps in cands:
|
| 181 |
+
path = os.path.join(ART, name + ".pkl")
|
| 182 |
+
try:
|
| 183 |
+
build(steps, path)
|
| 184 |
+
except Exception as e:
|
| 185 |
+
print(name, "BUILD FAIL", e); continue
|
| 186 |
+
bad, globs, ga = check_stream(path)
|
| 187 |
+
print(name, "bad:", bad, "getattr:", ga, "globals:", globs)
|