-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from base64 import b64decode | ||
|
||
text: str | ||
|
||
# read the file content | ||
with open('b64.txt', 'r') as file: | ||
text = file.readline() | ||
|
||
# Decode 50 times | ||
for i in range(50): | ||
text = b64decode(text) | ||
|
||
print(text.decode()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from requests import get | ||
result = '' | ||
next_port = 1337 | ||
|
||
current_number = float(0) | ||
IP = "10.10.250.0" | ||
|
||
while True: # next_port != 9765 or result != 'STOP' | ||
try: | ||
result = get(f'http://{IP}:{str(next_port)}').text | ||
|
||
if result == "STOP": | ||
break | ||
|
||
print(result) | ||
# add 900 23456 | ||
args = result.split() | ||
operation = args[0] | ||
new_number = float(args[1]) | ||
next_port = args[2] | ||
|
||
if next_port == 9765: | ||
break | ||
|
||
if operation == "add": | ||
current_number += float(new_number) | ||
elif operation == "minus": | ||
current_number -= float(new_number) | ||
elif operation == "multiply": | ||
current_number *= float(new_number) | ||
elif operation == "divide": | ||
current_number /= float(new_number) | ||
else: | ||
continue | ||
except Exception as error: | ||
pass | ||
|
||
|
||
|
||
print(current_number) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Scripting Room | ||
|
||
[Room Link](https://tryhackme.com/room/scripting) | ||
|
||
|
||
## Task 1 [Easy] Base64 | ||
[50-Decoder](50-decoder.py) | ||
|
||
|
||
> - This file has been base64 encoded 50 times - write a script to retrieve the flag. Here is the general process to do this: | ||
> | ||
> - read input from the file | ||
> | ||
> - use function to decode the file | ||
> | ||
> - do process in a loop | ||
> | ||
> - Try do this in both Bash and Python! | ||
> | ||
```python | ||
from base64 import b64decode | ||
|
||
text: str | ||
|
||
# read the file content | ||
with open('b64.txt', 'r') as file: | ||
text = file.readline() | ||
|
||
# Decode 50 times | ||
for i in range(50): | ||
text = b64decode(text) | ||
|
||
print(text.decode()) | ||
``` | ||
|
||
|
||
> What is the final string? | ||
> HackBack2019= | ||
|
||
## Task 2 [Medium] Gotta Catch em All | ||
[Gotta Catch em All](Gotta-Catch-em-All.py) | ||
> You need to write a script that connects to this webserver on the | ||
correct port, do an operation on a number and then move onto the next | ||
port. 0. | ||
> | ||
> The format is: *operation, number, next port.* | ||
> | ||
> For example the website might display, add 900 3212 which would be: add 900 and move onto port 3212. | ||
> | ||
> Then if it was minus 212 3499, you'd minus 212 (from the previous number which was 900) and move onto the next port 3499 | ||
> | ||
> Do this until you the page response is STOP (or you hit port 9765). | ||
> | ||
> Each | ||
port is also only live for 4 seconds. After that it goes to the next | ||
port. You might have to wait until port 1337 becomes live again... | ||
> | ||
> Go to: http://<machines_ip>:3010 to start... | ||
> | ||
> General Approach(it's best to do this using the sockets library in Python): | ||
> 1. Create a socket in Python using the [sockets](https://docs.python.org/3/howto/sockets.html) library | ||
> 2. Connect to the port | ||
> | ||
> 3. Send an operation | ||
> | ||
> 4. View response and continue | ||
> | ||
 | ||
|
||
> Once you have done all operations, what number do you get (rounded to 2 decimal places at the end of your calculation)? | ||
> 344769.12 | ||
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.