an atomdrift project
Hostile 98% python Download

seabreeze 2.11.0

Memory-allocated resource payload validated for inline PE headersPython relaunches elevated after admin check

Evidence

imports ctypes lines 2–35
2:30… deploy functions
3
4author: Andreas Poehlmann
5"""
6import argparse
7import ctypes
8import logging
9import os
10import platform
11import shutil
12import subprocess
13import sys
14import tempfile
15import time
16import zipfile
17from textwrap import dedent
18from textwrap import indent
19from urllib.error import HTTPError
20from urllib.request import urlopen
21
22_GITHUB_REPO_URL = (
23 "https://raw.githubusercontent.com/ap--/python-seabreeze/master/os_support"
24)
25_UDEV_RULES_PATH = "/etc/udev/rules.d/10-oceanoptics.rules"
26_DRIVERS_ZIP_FN = "windows-driver-files.zip"
27_log = logging.getLogger(__name__)
28
29
30def _diff_files(file1, file2):
31 """diff two files using linux `diff`"""
32 try:
33 return subprocess.check_output(["diff", file1, file2]).decode("utf8")
34 except subprocess.CalledProcessError as err:
35 return err.output.decode("utf8") …
Interactive yes/no confirmation prompt text lines 38–61
38:19… rmation(question):
39 """require user input to continue"""
40 while True:
41 user_input = input(f"{question} [y/n] ").lower()
42 if user_input not in {"y", "n"}:
43 _log.info("Please enter 'y' or 'n'.")
44 elif user_input[0] == "n":
45 return False
46 else:
47 return True
48 time.sleep(0.1)
49
50
51def linux_install_udev_rules():
52 """verify and install the udev rules"""
53 parser = argparse.ArgumentParser()
54 parser.add_argument(
55 "--overwrite-existing",
56 help="overwrite rules if already present",
57 action="store_true",
58 )
59 parser.add_argument(
60 "rules",
61 …
Calls function named urlopen lines 82–91
82:12… _log.info("downloading rules from github")
83 udev_data = urlopen(url).read()
84 except HTTPError:
85 _log.error(f"can't download '{url}'")
86 sys.exit(1)
87 udev_tmp_file.write(udev_data)
88 udev_tmp_file.flush()
89
90 # check if rules need to be overwritten
91 if os.path.exists(_UDEV_R …
Broad exception returns failure sentinel lines 120–132
120:10… ndows only: check if running as admin"""
121 # noinspection PyBroadException
122 try:
123 return ctypes.windll.shell32.IsUserAnAdmin()
124 except Exception:
125 return False
126
127
128def _is_contained_in_dir(files, cdir=None):
129 cdir = os.path.abspath(cdir or os.path.curdir)
130 for f in files:
131 f_abs = os.path.abspath(f)
132 if not os.path.commonprefix((f_abs, cdir)).sta …
Python calls ShellExecute with runas lines 139–154
139:7… not _request_confirmation("Install windows drivers?"):
140 sys.exit(0)
141
142 if not _windows_is_admin():
143 # Re-run the program with admin rights
144 argv = [__file__] + sys.argv[1:]
145 ret = ctypes.windll.shell32.ShellExecuteW(
146 None,
147 "runas",
148 sys.executable,
149 subprocess.list2cmdline(argv),
150 None,
⋯4 lines

Showing the top 5 files — 7 more files (51 regions) not shown.

Keyboard shortcuts on this page: j for the next sample, k for the previous one, x to go back to the feed, d to download the original bytes, r to re-queue the sample for analysis.