SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Python extensions in WinDbg 
Alin Serdean 
Senior cloud engineer 
@cloudbaseit
About me 
• Mostly a kernel developer 
• Past year I have been working intensely to 
bring (Open vSwitch)OVS to Hyper-V 
• OVS is a production quality, multilayer 
virtual switch licensed under the open 
source Apache 2.0 license. 
• De facto standard in OpenStack 
• It is designed to support distribution across 
multiple physical servers
OVS use case
OVS features 
• LACP (IEEE 802.1AX-2008) 
• Standard 802.1Q VLAN model with trunking 
• STP (IEEE 802.1D-1998) 
• Multiple tunneling protocols (GRE, VXLAN, 
IPsec, GRE and VXLAN over IPsec) 
• Remote configuration protocol with C and 
Python bindings 
• Kernel and user-space forwarding engine 
options
Debuggers on Windows 
Microsoft Visual Studio Debugger 
- ships along with all versions of VS 
- good when you have sources 
- integrated UI 
- based on CodeView 
- good for userspace debugging 
- can be used kernel using the VisualDDK 
- less powerful
Debuggers on Windows 
SoftICE 
- one of the most popular debuggers in the 
90s 
- Nu-Mega Tech. -> Compuware -> Micro 
Focus -> no longer maintained  
- open source kernel debugger similar to 
SoftICE named Rasta Ring 0 Debugger (RR0D) 
- was designed to run live 
- Software vendors have put in place a wide 
range of countermeasures to protect themselves 
from people employing SoftICE as a tool to 
analyse software.
SoftICE 
mov eax, dword ptr [pIDT+2] ; eax -> IDT 
add eax, 8 ; eax -> int 1 vector 
mov ebx, [eax] ; ebx == int 1 vector 
add eax, 16 ; eax -> int 3 vector 
mov eax, [eax] ; eax == int 3 vector 
and eax, 0ffffh ; strip the selector 
and ebx, 0ffffh ; part of it 
sub eax, ebx ; find displacement 
cmp eax, 10h ; 
jne HackedVector ; if it isn't equal, then 
chances are SoftICE had tampered with these vectors
Debuggers on Windows 
• OllyDbg 
– x86 only 
– x64 under heavy development 
– Used for reverse engineering/cracking 
– Can be used for malware as well 
– Userspace only
Debuggers on Windows 
• Interactive Disassembler 
– Known as IDA 
– Was sold to DataRescue -> IDA Pro 
– Orig. author created Hex-Rays 
– Hex-Rays is back the dev. and support of IDA 
– Has support for scripting languages 
(IDARuby and IDAPython) through 
extensions. Latest IDA Pro release 
IDAPython is preinstalled  
– Has support over a variety of Instruction sets
Debuggers on Windows 
WinDbg 
– Well written documentation (MSDN) 
– Can be used for kernel-memory dumps 
– Can be used to debug: 
• Userspace 
• Drivers 
• OS itself! 
– x64 support  
– Has extensions loading them by DLLs (the ones 
that starts !)
Debuggers on Windows 
• WinDbg(contd’) 
– Has the ability to automatically load PDBs 
– Has support of multiple scripting languages 
• Proprietary looks a bit awful and has to few commands 
• Python through the kindness of the following: 
– PyDbgExt 
– PyKd 
• Ruby unstable at the moment: 
– https://github.com/bnagy/rBuggery 
– Free to use 
Python Extensions 
• PyDbgExt 
– Still alpha 
– Has to be recompiled on 8/8.1 
– Relies on boost 
– Highly unstable 
– No documentation
Python Extensions 
• PyKd - https://pykd.codeplex.com/ 
– It has installer  
– It has documentation 
– It has samples 
– Microsoft acknowledges it 
– Used by reverse engineers intensively 
– Decently stable 
– Highly maintained
Typical example of Windbg 
Script 
!for_each_module " 
.if(not(wo(dwo(${@#Base}+0x3c)+${@#Base}+46+18) & 0x40)) { 
r @$t3 = @#End - @#Base; 
.foreach /s (retn "C2 C3") { 
.foreach (f {s -[1]b @#Base L@$t3 ${retn}}) { 
.for(r @$t0 = 1; @$t0 < 4; r @$t0 = @$t0 + 1) { 
r @$t1 = 0; 
.foreach (g {.catch {u f - @$t0 L@$t0+1}}) { 
.if($spat("${g}", "*ret*") != 0) { 
r @$t1 = 1 
} 
}; 
.if(@$t1 == 1) { 
.printf "---------------------- size %x", @$t0; 
.echo; 
.catch {u f - @$t0 L@$t0+1} 
} 
} 
} 
} 
} 
"
• The example above is an example to find a 
specific vulnerability in Windows 
• It is used to find ROP gadgets 
• ROP - Return-oriented programming allows 
you to execute code in non-executable 
memory and code signing. 
• The script above bypasses ASLR(Address 
space layout randomization) 
• It searches for the Optional PE Header 
(DllCharacteristics) then checks for the 
IMAGE_DLLCHARACTERISTICS_DYNAMI 
C_BASE 0x0040 flag
WinDbg print process 
r? @$t0=(nt!_LIST_ENTRY*)@@(nt!PsActiveProcessHead) 
.for (r? @$t1 = @$t0->Flink; 
(@$t1!=@$t0); 
r?@$t1 = @$t1->Flink) 
{ 
r? @$t2 = #CONTAINING_RECORD(@$t1, nt!_EPROCESS, ActiveProcessLinks) 
as /x $ProcPid @@(@$t2->UniqueProcessId) 
as /ma $ProcName @@(@$t2->ImageFileName) 
as /x $Temp @$t2 
as /x $Temp2 @@(@$t2->UniqueProcessId) 
.block { .echo ${$Temp} ${$Temp2}} 
.block {.echo ${$ProcName} with PID ${$ProcPid} } 
ad $ProcName 
ad $ProcPid 
ad $Temp 
}
Same script in PyKd 
import sys 
from pykd import * 
nt = module( "nt" ) 
processList = typedVarList( nt.PsActiveProcessHead, 
"nt!_EPROCESS", "ActiveProcessLinks" ) 
j = 1 
for process in processList: 
dprint("Process "+str(j)+": ") 
print "".join( [chr(i) for i in process.ImageFileName if i != 0] ) 
j += 1
PyKd contd’ Listing all Namespaces of 
WebServiceMethod 
from pykd import * 
def dump_soapclientmethod(): 
# get all SoapClientMethod's 
soapcliaddrs = pykd.dbgCommand("!dumpheap -mt 0000064283abea38 - 
short").split("n") 
print "### found %d soap client addresses" % (len(soapcliaddrs)) 
for addr in soapcliaddrs: 
# dumpobj to get object properties 
do = pykd.dbgCommand("!do %(addr)s" % { 'addr': addr }) 
# get the line for 'action' property 
actionline = [line for line in do.split('n') if 'action' in line] 
# line ends with "<address> action" and we want the <address> 
actionaddr = actionline[0].split()[-2] 
# get the string in the retrieved <address> 
doaction = pykd.dbgCommand("!do -nofields %(addr)s" % {'addr': 
actionaddr}).split("n") 
print "%s -> %s" % (actionaddr, doaction[-2])
• the code above renders an output like: 
### found 125 soap client addresses 
00000001c1755b48 -> String: 
http://schemas.microsoft.com/sharepoint/soap/List 
00000001e2085640 -> String: 
http://schemas.microsoft.com/sharepoint/soap/Copy 
0000000240fb35c8 -> String: 
http://schemas.microsoft.com/sharepoint/soap/List 
00000002419c4158 -> String: 
http://schemas.microsoft.com/sharepoint/soap/Copy 
...
Q & A

Weitere ähnliche Inhalte

Was ist angesagt?

Fluentd and PHP
Fluentd and PHPFluentd and PHP
Fluentd and PHP
chobi e
 
OpenNebula Conf 2014: CentOS, QA an OpenNebula - Christoph Galuschka
OpenNebula Conf 2014: CentOS, QA an OpenNebula - Christoph GaluschkaOpenNebula Conf 2014: CentOS, QA an OpenNebula - Christoph Galuschka
OpenNebula Conf 2014: CentOS, QA an OpenNebula - Christoph Galuschka
NETWAYS
 
01 linux-quick-start
01 linux-quick-start01 linux-quick-start
01 linux-quick-start
Nguyen Vinh
 

Was ist angesagt? (20)

Ищем уязвимости нулевого дня в ядре Linux
Ищем уязвимости нулевого дня в ядре LinuxИщем уязвимости нулевого дня в ядре Linux
Ищем уязвимости нулевого дня в ядре Linux
 
Docker meetup
Docker meetupDocker meetup
Docker meetup
 
Lua and its Ecosystem
Lua and its EcosystemLua and its Ecosystem
Lua and its Ecosystem
 
Fluentd and PHP
Fluentd and PHPFluentd and PHP
Fluentd and PHP
 
libuv, NodeJS and everything in between
libuv, NodeJS and everything in betweenlibuv, NodeJS and everything in between
libuv, NodeJS and everything in between
 
Abusing Interrupts for Reliable Windows Kernel Exploitation (en)
Abusing Interrupts for Reliable Windows Kernel Exploitation (en)Abusing Interrupts for Reliable Windows Kernel Exploitation (en)
Abusing Interrupts for Reliable Windows Kernel Exploitation (en)
 
Michele Dionisio & Pietro Lorefice - Developing and testing a device driver w...
Michele Dionisio & Pietro Lorefice - Developing and testing a device driver w...Michele Dionisio & Pietro Lorefice - Developing and testing a device driver w...
Michele Dionisio & Pietro Lorefice - Developing and testing a device driver w...
 
Titanium 3.2 CLI - TiAppCamp2 - 11/2/2013
Titanium 3.2 CLI - TiAppCamp2 - 11/2/2013Titanium 3.2 CLI - TiAppCamp2 - 11/2/2013
Titanium 3.2 CLI - TiAppCamp2 - 11/2/2013
 
Exploring the Titanium CLI - Codestrong 2012
Exploring the Titanium CLI - Codestrong 2012Exploring the Titanium CLI - Codestrong 2012
Exploring the Titanium CLI - Codestrong 2012
 
LibreSSL, one year later
LibreSSL, one year laterLibreSSL, one year later
LibreSSL, one year later
 
Testing Wi-Fi with OSS Tools
Testing Wi-Fi with OSS ToolsTesting Wi-Fi with OSS Tools
Testing Wi-Fi with OSS Tools
 
Syslog Protocols
Syslog ProtocolsSyslog Protocols
Syslog Protocols
 
Fluentd - CNCF Paris
Fluentd - CNCF ParisFluentd - CNCF Paris
Fluentd - CNCF Paris
 
OpenNebula Conf 2014: CentOS, QA an OpenNebula - Christoph Galuschka
OpenNebula Conf 2014: CentOS, QA an OpenNebula - Christoph GaluschkaOpenNebula Conf 2014: CentOS, QA an OpenNebula - Christoph Galuschka
OpenNebula Conf 2014: CentOS, QA an OpenNebula - Christoph Galuschka
 
Snaps on open suse
Snaps on open suseSnaps on open suse
Snaps on open suse
 
Rihards Olups - Encrypting Daemon Traffic With Zabbix 3.0
Rihards Olups - Encrypting Daemon Traffic With Zabbix 3.0Rihards Olups - Encrypting Daemon Traffic With Zabbix 3.0
Rihards Olups - Encrypting Daemon Traffic With Zabbix 3.0
 
From nothing to Prometheus : one year after
From nothing to Prometheus : one year afterFrom nothing to Prometheus : one year after
From nothing to Prometheus : one year after
 
嵌入式Linux課程-GNU Toolchain
嵌入式Linux課程-GNU Toolchain嵌入式Linux課程-GNU Toolchain
嵌入式Linux課程-GNU Toolchain
 
01 linux-quick-start
01 linux-quick-start01 linux-quick-start
01 linux-quick-start
 
OpenWrt From Top to Bottom
OpenWrt From Top to BottomOpenWrt From Top to Bottom
OpenWrt From Top to Bottom
 

Andere mochten auch

Andere mochten auch (15)

MyCloud for $100k
MyCloud for $100kMyCloud for $100k
MyCloud for $100k
 
Making of-the-logistic-map-bifurcation-diagram
Making of-the-logistic-map-bifurcation-diagramMaking of-the-logistic-map-bifurcation-diagram
Making of-the-logistic-map-bifurcation-diagram
 
Working in the multi-cloud with libcloud
Working in the multi-cloud with libcloudWorking in the multi-cloud with libcloud
Working in the multi-cloud with libcloud
 
CernVM-FS for Docker image distribution in Cloud Foundry
CernVM-FS for Docker image distribution in Cloud FoundryCernVM-FS for Docker image distribution in Cloud Foundry
CernVM-FS for Docker image distribution in Cloud Foundry
 
Immutable Systems in the AWS Cloud
Immutable Systems in the AWS CloudImmutable Systems in the AWS Cloud
Immutable Systems in the AWS Cloud
 
Modern Web development and operations practices
Modern Web development and operations practicesModern Web development and operations practices
Modern Web development and operations practices
 
Rackspace & Akamai vs. Amazon & CloudFront for a Django site
Rackspace & Akamai vs. Amazon & CloudFront for a Django siteRackspace & Akamai vs. Amazon & CloudFront for a Django site
Rackspace & Akamai vs. Amazon & CloudFront for a Django site
 
Bind Python and C @ COSCUP 2015
Bind Python and C @ COSCUP 2015Bind Python and C @ COSCUP 2015
Bind Python and C @ COSCUP 2015
 
Cloud Academy & AWS: how we use Amazon Web Services for machine learning and ...
Cloud Academy & AWS: how we use Amazon Web Services for machine learning and ...Cloud Academy & AWS: how we use Amazon Web Services for machine learning and ...
Cloud Academy & AWS: how we use Amazon Web Services for machine learning and ...
 
Boost.Python: C++ and Python Integration
Boost.Python: C++ and Python IntegrationBoost.Python: C++ and Python Integration
Boost.Python: C++ and Python Integration
 
CS1 and Python
CS1 and PythonCS1 and Python
CS1 and Python
 
The Go features I can't live without, 2nd round
The Go features I can't live without, 2nd roundThe Go features I can't live without, 2nd round
The Go features I can't live without, 2nd round
 
Подключение внешних библиотек в python
Подключение внешних библиотек в pythonПодключение внешних библиотек в python
Подключение внешних библиотек в python
 
Недостатки Python
Недостатки PythonНедостатки Python
Недостатки Python
 
Interfacing C/C++ and Python with SWIG
Interfacing C/C++ and Python with SWIGInterfacing C/C++ and Python with SWIG
Interfacing C/C++ and Python with SWIG
 

Ähnlich wie Ropython-windbg-python-extensions

"Making OpenCV Code Run Fast," a Presentation from Intel
"Making OpenCV Code Run Fast," a Presentation from Intel"Making OpenCV Code Run Fast," a Presentation from Intel
"Making OpenCV Code Run Fast," a Presentation from Intel
Edge AI and Vision Alliance
 
The future of server side JavaScript
The future of server side JavaScriptThe future of server side JavaScript
The future of server side JavaScript
Oleg Podsechin
 

Ähnlich wie Ropython-windbg-python-extensions (20)

Introduction to Docker and deployment and Azure
Introduction to Docker and deployment and AzureIntroduction to Docker and deployment and Azure
Introduction to Docker and deployment and Azure
 
Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...
Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...
Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...
 
Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)
 
Introduction to Docker at the Azure Meet-up in New York
Introduction to Docker at the Azure Meet-up in New YorkIntroduction to Docker at the Azure Meet-up in New York
Introduction to Docker at the Azure Meet-up in New York
 
"Making OpenCV Code Run Fast," a Presentation from Intel
"Making OpenCV Code Run Fast," a Presentation from Intel"Making OpenCV Code Run Fast," a Presentation from Intel
"Making OpenCV Code Run Fast," a Presentation from Intel
 
VB2013 - Security Research and Development Framework
VB2013 - Security Research and Development FrameworkVB2013 - Security Research and Development Framework
VB2013 - Security Research and Development Framework
 
Docker and-containers-for-development-and-deployment-scale12x
Docker and-containers-for-development-and-deployment-scale12xDocker and-containers-for-development-and-deployment-scale12x
Docker and-containers-for-development-and-deployment-scale12x
 
From Zero to Hero - All you need to do serious deep learning stuff in R
From Zero to Hero - All you need to do serious deep learning stuff in R From Zero to Hero - All you need to do serious deep learning stuff in R
From Zero to Hero - All you need to do serious deep learning stuff in R
 
App container rkt
App container rktApp container rkt
App container rkt
 
Debugging Python with gdb
Debugging Python with gdbDebugging Python with gdb
Debugging Python with gdb
 
Workshop : 45 minutes pour comprendre Docker avec Jérôme Petazzoni
Workshop : 45 minutes pour comprendre Docker avec Jérôme PetazzoniWorkshop : 45 minutes pour comprendre Docker avec Jérôme Petazzoni
Workshop : 45 minutes pour comprendre Docker avec Jérôme Petazzoni
 
Introduction to Docker, December 2014 "Tour de France" Edition
Introduction to Docker, December 2014 "Tour de France" EditionIntroduction to Docker, December 2014 "Tour de France" Edition
Introduction to Docker, December 2014 "Tour de France" Edition
 
The future of server side JavaScript
The future of server side JavaScriptThe future of server side JavaScript
The future of server side JavaScript
 
Zenoh Tutorial
Zenoh TutorialZenoh Tutorial
Zenoh Tutorial
 
Docker Multi Host Networking, Rachit Arora, IBM
Docker Multi Host Networking, Rachit Arora, IBMDocker Multi Host Networking, Rachit Arora, IBM
Docker Multi Host Networking, Rachit Arora, IBM
 
Настройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'aНастройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'a
 
React native
React nativeReact native
React native
 
You're Off the Hook: Blinding Security Software
You're Off the Hook: Blinding Security SoftwareYou're Off the Hook: Blinding Security Software
You're Off the Hook: Blinding Security Software
 
Docker module 1
Docker module 1Docker module 1
Docker module 1
 
LibOS as a regression test framework for Linux networking #netdev1.1
LibOS as a regression test framework for Linux networking #netdev1.1LibOS as a regression test framework for Linux networking #netdev1.1
LibOS as a regression test framework for Linux networking #netdev1.1
 

Kürzlich hochgeladen

VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 

Kürzlich hochgeladen (20)

VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 

Ropython-windbg-python-extensions

  • 1. Python extensions in WinDbg Alin Serdean Senior cloud engineer @cloudbaseit
  • 2. About me • Mostly a kernel developer • Past year I have been working intensely to bring (Open vSwitch)OVS to Hyper-V • OVS is a production quality, multilayer virtual switch licensed under the open source Apache 2.0 license. • De facto standard in OpenStack • It is designed to support distribution across multiple physical servers
  • 4. OVS features • LACP (IEEE 802.1AX-2008) • Standard 802.1Q VLAN model with trunking • STP (IEEE 802.1D-1998) • Multiple tunneling protocols (GRE, VXLAN, IPsec, GRE and VXLAN over IPsec) • Remote configuration protocol with C and Python bindings • Kernel and user-space forwarding engine options
  • 5. Debuggers on Windows Microsoft Visual Studio Debugger - ships along with all versions of VS - good when you have sources - integrated UI - based on CodeView - good for userspace debugging - can be used kernel using the VisualDDK - less powerful
  • 6. Debuggers on Windows SoftICE - one of the most popular debuggers in the 90s - Nu-Mega Tech. -> Compuware -> Micro Focus -> no longer maintained  - open source kernel debugger similar to SoftICE named Rasta Ring 0 Debugger (RR0D) - was designed to run live - Software vendors have put in place a wide range of countermeasures to protect themselves from people employing SoftICE as a tool to analyse software.
  • 7. SoftICE mov eax, dword ptr [pIDT+2] ; eax -> IDT add eax, 8 ; eax -> int 1 vector mov ebx, [eax] ; ebx == int 1 vector add eax, 16 ; eax -> int 3 vector mov eax, [eax] ; eax == int 3 vector and eax, 0ffffh ; strip the selector and ebx, 0ffffh ; part of it sub eax, ebx ; find displacement cmp eax, 10h ; jne HackedVector ; if it isn't equal, then chances are SoftICE had tampered with these vectors
  • 8. Debuggers on Windows • OllyDbg – x86 only – x64 under heavy development – Used for reverse engineering/cracking – Can be used for malware as well – Userspace only
  • 9. Debuggers on Windows • Interactive Disassembler – Known as IDA – Was sold to DataRescue -> IDA Pro – Orig. author created Hex-Rays – Hex-Rays is back the dev. and support of IDA – Has support for scripting languages (IDARuby and IDAPython) through extensions. Latest IDA Pro release IDAPython is preinstalled  – Has support over a variety of Instruction sets
  • 10. Debuggers on Windows WinDbg – Well written documentation (MSDN) – Can be used for kernel-memory dumps – Can be used to debug: • Userspace • Drivers • OS itself! – x64 support  – Has extensions loading them by DLLs (the ones that starts !)
  • 11. Debuggers on Windows • WinDbg(contd’) – Has the ability to automatically load PDBs – Has support of multiple scripting languages • Proprietary looks a bit awful and has to few commands • Python through the kindness of the following: – PyDbgExt – PyKd • Ruby unstable at the moment: – https://github.com/bnagy/rBuggery – Free to use 
  • 12. Python Extensions • PyDbgExt – Still alpha – Has to be recompiled on 8/8.1 – Relies on boost – Highly unstable – No documentation
  • 13. Python Extensions • PyKd - https://pykd.codeplex.com/ – It has installer  – It has documentation – It has samples – Microsoft acknowledges it – Used by reverse engineers intensively – Decently stable – Highly maintained
  • 14. Typical example of Windbg Script !for_each_module " .if(not(wo(dwo(${@#Base}+0x3c)+${@#Base}+46+18) & 0x40)) { r @$t3 = @#End - @#Base; .foreach /s (retn "C2 C3") { .foreach (f {s -[1]b @#Base L@$t3 ${retn}}) { .for(r @$t0 = 1; @$t0 < 4; r @$t0 = @$t0 + 1) { r @$t1 = 0; .foreach (g {.catch {u f - @$t0 L@$t0+1}}) { .if($spat("${g}", "*ret*") != 0) { r @$t1 = 1 } }; .if(@$t1 == 1) { .printf "---------------------- size %x", @$t0; .echo; .catch {u f - @$t0 L@$t0+1} } } } } } "
  • 15. • The example above is an example to find a specific vulnerability in Windows • It is used to find ROP gadgets • ROP - Return-oriented programming allows you to execute code in non-executable memory and code signing. • The script above bypasses ASLR(Address space layout randomization) • It searches for the Optional PE Header (DllCharacteristics) then checks for the IMAGE_DLLCHARACTERISTICS_DYNAMI C_BASE 0x0040 flag
  • 16. WinDbg print process r? @$t0=(nt!_LIST_ENTRY*)@@(nt!PsActiveProcessHead) .for (r? @$t1 = @$t0->Flink; (@$t1!=@$t0); r?@$t1 = @$t1->Flink) { r? @$t2 = #CONTAINING_RECORD(@$t1, nt!_EPROCESS, ActiveProcessLinks) as /x $ProcPid @@(@$t2->UniqueProcessId) as /ma $ProcName @@(@$t2->ImageFileName) as /x $Temp @$t2 as /x $Temp2 @@(@$t2->UniqueProcessId) .block { .echo ${$Temp} ${$Temp2}} .block {.echo ${$ProcName} with PID ${$ProcPid} } ad $ProcName ad $ProcPid ad $Temp }
  • 17. Same script in PyKd import sys from pykd import * nt = module( "nt" ) processList = typedVarList( nt.PsActiveProcessHead, "nt!_EPROCESS", "ActiveProcessLinks" ) j = 1 for process in processList: dprint("Process "+str(j)+": ") print "".join( [chr(i) for i in process.ImageFileName if i != 0] ) j += 1
  • 18. PyKd contd’ Listing all Namespaces of WebServiceMethod from pykd import * def dump_soapclientmethod(): # get all SoapClientMethod's soapcliaddrs = pykd.dbgCommand("!dumpheap -mt 0000064283abea38 - short").split("n") print "### found %d soap client addresses" % (len(soapcliaddrs)) for addr in soapcliaddrs: # dumpobj to get object properties do = pykd.dbgCommand("!do %(addr)s" % { 'addr': addr }) # get the line for 'action' property actionline = [line for line in do.split('n') if 'action' in line] # line ends with "<address> action" and we want the <address> actionaddr = actionline[0].split()[-2] # get the string in the retrieved <address> doaction = pykd.dbgCommand("!do -nofields %(addr)s" % {'addr': actionaddr}).split("n") print "%s -> %s" % (actionaddr, doaction[-2])
  • 19. • the code above renders an output like: ### found 125 soap client addresses 00000001c1755b48 -> String: http://schemas.microsoft.com/sharepoint/soap/List 00000001e2085640 -> String: http://schemas.microsoft.com/sharepoint/soap/Copy 0000000240fb35c8 -> String: http://schemas.microsoft.com/sharepoint/soap/List 00000002419c4158 -> String: http://schemas.microsoft.com/sharepoint/soap/Copy ...
  • 20. Q & A