Notes test

THM_Notes.ctb

TryHackMe


Tools


Powershell


Powershell commands are cmdlets

Powershell can view Alternate Data Streams (ADS)
$DATA
Windows explorer doesnt allow this
Used to Hide malware

Commands


Get-Help = obtain cmdlet info
Get-ChildItem = list contents of directory
Get-FileHash = Append w/ desired algo
Get-Content = Reads contents of a file
-Path = Specifies path
-File / -Directory = list flies/directories
-Filter = Qualify Path paremeter
-Recurse = Gets items in locations
-Hidden = Get only hidden items
-Algorythm = Sets the algo for GetHash
Measure-Object = Counts output of file
-Word = Used with | to output
Set-Location = Change directories
Select-String = Search for a pattern
ErrorAction SilentlyContinue = Handles errors

EX:
To view all hidden files in current directory
Get-ChildItem -File -Hidden -ErrorAction SilentlyContinue

To change location to admins desktop
Set-Location -Path c:\users\administrator\desktop

To get the number of words in a file
Get-Content -Path file.txt | MeasureObject -Word

To look for PDF's in the admins desktop
Select-String -Path 'c:\users\administrator\desktop’ -Pattern ‘*.pdf’

-Filter '*3*'

Command line examples:
Getting the string for redryder
images/9-1.png
Finding hidden files
images/9-2.png
Looking at contents of hidden files
images/9-3.png

ADS


You can use the strings tool to view ADS binaries
images/10-1.png

You can find hidden things inside of files by parsing through the string

ReverseEngineering


How to go through assembly x86-64 to look through system memory

Using the tool rdare2 that dissassembles the bianaries

How to use the .NET framework

How to use Remmina and ILSpy

rdare2


Use the command
r2 -d ./file1

Then to analyze it use
aa

to find a list of functions use
afl

to examine assembly code use
pdf@ main
images/2-1.png
images/2-2.png

set a breakpoint using
db 0x00400b55

verify using print dissassembly function
pdf @main

now run the program using (continue)
dc

run print dissassembly function again
pdf @main

images/2-3.pngtells cpu where we are in the the code
rip is 64 bit version instruction
mov – transfers values
moves to a double word variable
value of 4 (look @ table)

enter the command for the var int local
px @rbp-0xc

prints in hex use the command step to move on to the next instruction
ds

user the display register command to see contents
dr
images/2-4.png

they correspond to the local_ch and move through the instructions at that rate.

.NET


Use RDP and ILSpy to decompite .NET malware



Remmina


Open up remmina to connect to an RDP client on Linux


images/5-1.png

ILSpy


Open up IL spy

images/6-1.png
images/6-2.png

1. Navigate to the TBFC App
2. Found the CrackMe interesting and looked inside
3. Found an interesting thing labeled unsafe

images/6-3.png

Opened it up and found a password and a flag

Hydra


Bruteforce SSH


images/21-1.png

John


John The Ripper

Using with a wordlist
images/25-1.png

To convert an ssh passphrase to John format
images/25-2.png


Use format to force a format crack (md5)
images/25-3.png

use the hash-id.py script to get the format
images/25-4.png


Services


Samba


Share service for Windows
uses ports 445 and 139
Verify with Nmap general scan
use nmap scripts to enum

Enumerating SMB shares

nmap -p 445 --script=smb-enum-shares.nse,smb-enum-users.nse 10.10.0.252

images/11-1.png

3 shares open

connecting to a share
images/11-2.png

Downloading a share
images/11-3.png

FTP


port 21

can use nc to connect to
images/12-1.png

ProFTPD module


Very exploitable
– Check version
images/13-1.png
– Info
http://www.proftpd.org/docs/contrib/mod_copy.html

use commands to copy a file
images/13-2.png
This copied the RSA ID key to a file on my local machine
SITE
CPFR
CPTO

NFS


Install the nfs-common suite
sudo apt install nfs-common

scan the target with nmap to verify
nmap -A -p- <ip>
show the nfs shares
/usr/sbin/showmount -e [IP]
make a directort in tmp to mount the enumed share
mkdir /tmp/mount
sudo mount -t nfs 10.10.76.163:home /tmp/mount/ -nolock


images/15-1.png
images/15-2.png

SMTP


Uses port 25

use Metasploit to enumerate/exploit
Modules:
auxiliary/scanner/smtp/smtp_version
auxiliary/scanner/smtp/smtp_enum

images/16-1.png

MySQL


Database system

to login: (assuming you have creds)
mysql -h <IP> -u <Username> -p
images/22-1.png

Use metasploit to attack

images/22-2.png

the mysql_schema dump and mysql_sql modules to enumerate

set RHOSTS, PASSWORD, USERNAME

Use hashdump to get a hash

images/22-3.png

You can grab a user hash and run it against John to get a password. Use this info to login to SSH (password reuse exploit)
images/22-4.png

Put the user/hash into a txt so John can crack it
images/22-5.png


Web Attacks


SSRF


Server Side Request Forgery

– Forces a web app to make request to resources that it normally would not

EX: Web app can produce screenshots of other websites when user submits a URL and the attacker could submit internal IP address to get a screenshot of internal resources



images/7-1.png

The TLD here is not a FQDN and points to something on the inside
Use a URL decoder to get better info

images/7-2.png

Try and get root with
http://10.10.244.9/?proxy=http%3A%2F%2Flist.hohoho%3A8080%2F
The result is the page can not be found
It is an indicator the site may be vulerable to SSRF

Next try and change the port to 22 instead of 8080
http://10.10.244.9/?proxy=http%3A%2F%2Flist.hohoho%3A22
This will attempt to exectue and indicate that the port is open. However because we are just using a web browser we cannot SSH into it and the page will error out.


Net try and connect to the local host
images/7-3.png

We have been blocked but can try and bypass that

Set the name to
http://10.10.166.162/?proxy=http%3A%2F%2Flist.hohoho.localtest.me


This will treat us as a local user and possibly display some useful info

Cryptography


Modulo

images/23-1.png

Symmetric vs Asymmetric
same key diff key
AES RSA
DES EC

Digital Signatures/Certificates
Root CA

RSA


Rivest Shamir Adleman

RSA decryption tools

https://github.com/Ganapati/RsaCtfTool

https://github.com/ius/rsatool

Goole RSA calculator

RSA for CTF
“p” “q” are large prime numbers
“n” is the product of p & q
The public key is “n” and “d”
The private key is “n” and “e”
“m” represents the num in plaintext
“c” represents cyphertext

GPG



GNU Pretty Good Privacy

Man page

https://www.gnupg.org/gph/de/manual/r1023.html

Crack using gpg2john

1. Import the secret key
2. Verify
3. Decrypt using the key
images/26-1.png

Leave a comment