*Scripting (TryHackMe)
TryHackMe - Scripting Write-Up
This room covers basic scripting challenges including easy, medium and hard difficulty levels. I will be using Python with Sublime text editor.
Easy
Medium
Hard
Easy
Plan
Thankfully I've been exposed to this process so it shouldn't be too difficult. We will need to
import the base64 library and all its contingencies
read the encoded file into the program and store into separate variable
create a for loop to run 50 times, using the decode function on the new variable and storing each instance of decoding into that same variable
close the file and print the contents
Code
Result
We can decode the string from utf-8 to get rid of the b ' ' which represents that we encoded it to utf-8 and it's now a bytes object.
Medium
We need to write a script that connects to the given webserver on the given port, do an arithmetic operation and move to the next port. We are told to begin at 0 and stop when we hit port 9765.
Plan
import socket, sys and time libraries
socket to open a connection to the webserver and send a GET request to receive the operation and number on each port
sys for general system methods
time for the HTTP reponse, each port is only open for 4 seconds
use an if loop under a try statement until the port reaches 9765
connect to the webserver on port 1337
send get request to fetch some server object (aka the operation type & arithmetic)
encode/process response (trim, replace, split)
perform arithmetic based on the array (0- operation, 1 - arithmetic type, 2- port)
the arithmetic bounces between random ports until it reaches end port
store the resulting number in a variable and keeping looping until the port equals 9765
Code
.replace and .strip explanation
Result
Hard
todo***************************
Plan
Code
Result
Last updated