Home
Calendar
Certifications
Columns
Features
Forum
Resources
Vitals
Latest Additions
April 2013 Free Giveaway Sponsor - eLearnSecurity
Human Intelligence to Navigate the Security Data Deluge
February 2013 Free Giveaway Winner of SANS CyberCon Training
Interview: Bugcrowd Founders on Herding Ninjas for Crowdsourced Bug Bounties
Network Forensics: The Tree in the Forest
March 2013 Free Giveaway Sponsor - Mile2
Book Review: Violent Python
February 2013 Free Giveaway Sponsor - SANS
Holiday 2012 Free Giveaway Winner of Metasploit Pro by Rapid7
Course Review: SANS FOR408 Computer Forensic Investigations – Windows In-Depth
The Security Consulting Sugar High
Tutorial: Fun with SMB on the Command Line
Interview: Ilia Kolochenko, CEO of High-Tech Bridge
October 2012 Free Giveaway Winner of LearningGate Training
The Broken: Assessing Corporate Security in 2012 to Make a Better 2013
EH-Net Login
Welcome Guest.
Username:
Password:
Remember me
Lost Password?
No account yet?
Register
Who's Online
We have 33 guests and 1 member online
You are here:
Home
Ethical Hacking Discussions and Related Certifications
Programming
Problem with a shellcode...
EH-Net
May 19, 2013, 08:52:44 PM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
: Go back to The Ethical Hacker Network Online Magazine
Home Page
Home
Help
Calendar
Login
Register
EH-Net
>
Ethical Hacking Discussions and Related Certifications
>
Programming
(Moderator:
don
) >
Problem with a shellcode...
Pages: [
1
]
2
3
Go Down
« previous
next »
Print
Author
Topic: Problem with a shellcode... (Read 17398 times)
0 Members and 1 Guest are viewing this topic.
H1t M0nk3y
Hero Member
Offline
Posts: 864
Problem with a shellcode...
«
on:
May 13, 2010, 07:17:28 AM »
Hi,
I have an odd problem when trying to write my own exploit. I am doing the "extra mile" exercises for Win32 the Buffer-Overflow in the PWB course. So everything I am doing is legal here. Everything goes very well but one little thing.
I understand that injecting a null byte (\x00) will cause problems during the execution. But I have discovered that when I try to inject bytes ranging from \x0A to \x0F, I get a similar problem. Here is an example:
Let's say I want to inject the following code:
\x41\x42\x43\x44\x45
\x0A
\x46\x47\x48\x49
The debugger will show that the end result is something like:
\x41\x42\x43\x44\x45
\x5A\x6B\x31\x5C\x61
But if I remove this \x0A character, I get the full message copied at the proper location: \x41\x42\x43\x44\x45\x46\x47\x48\x49
Basically, it seems I successfully copy my code, but starting at one of the mentioned characters, I only get garbage...
Any REAL experts?
Logged
OSCP, GPEN, GWAPT, GSEC, CEH, CISSP
zeroflaw
Full Member
Offline
Posts: 208
Re: Problem with a shellcode...
«
Reply #1 on:
May 13, 2010, 07:47:48 AM »
Hmm 0x0A is the newline character, and the other chars are like tabs and a carriage return. Maybe it breaks the shellcode somehow. Though I've only read that shellcode can't contain null bytes
«
Last Edit: May 13, 2010, 07:52:20 AM by zeroflaw
»
Logged
ZF
H1t M0nk3y
Hero Member
Offline
Posts: 864
Re: Problem with a shellcode...
«
Reply #2 on:
May 13, 2010, 07:51:49 AM »
I forgot to say I am using a VPN. I first thought my firewall could be blocking these characters, but I soon woke up and realize the VPN encrypts everything. So it isn't my firewall.
Could it be an encoding problem of some sort?
Logged
OSCP, GPEN, GWAPT, GSEC, CEH, CISSP
mambru
Jr. Member
Offline
Posts: 98
Re: Problem with a shellcode...
«
Reply #3 on:
May 13, 2010, 11:19:36 AM »
The null byte (\x00) is not the only byte that may finish your string. Before crafting your payload you must detect which bytes will cause the application to finish your string, so you avoid them in the payload.
Check the next url for reference:
http://en.wikibooks.org/wiki/Metasploit/WritingWindowsExploit#Dealing_with_badchars
Logged
H1t M0nk3y
Hero Member
Offline
Posts: 864
Re: Problem with a shellcode...
«
Reply #4 on:
May 13, 2010, 12:33:48 PM »
Thanks mambru, I will read it tonight.
Also, I will post my solution.
Logged
OSCP, GPEN, GWAPT, GSEC, CEH, CISSP
sil
Hero Member
Offline
Posts: 549
Re: Problem with a shellcode...
«
Reply #5 on:
May 13, 2010, 03:53:55 PM »
Quote from: H1t M0nk3y on May 13, 2010, 07:17:28 AM
Let's say I want to inject the following code:
\x41\x42\x43\x44\x45
\x0A
\x46\x47\x48\x49
The debugger will show that the end result is something like:
\x41\x42\x43\x44\x45
\x5A\x6B\x31\x5C\x61
Any REAL experts?
NOP's are 90's... In that case, xor eax, eax is your friend... You can replace NOP's by zeroing them out, replacing them, etc.. e.g.:
Code:
\x31\xdb\x31\xc0\xb0\x01\xcd\x80
//xor eax,eax
//xor ebx,ebx
//mov al,1
//int 0x80
http://lordparody.wordpress.com/2010/03/09/just-slide/
http://www.vividmachines.com/shellcode/shellcode.html#as
http://mishou.org/2009/12/12/insecure-programming-by-example-shellcode-stack5-c/
http://webcache.googleusercontent.com/search?q=cache:ToYj-Yq3m-UJ:nostarch.com/extras/hacking/chap2/print2.asm+zero+out+nop+sled&cd=6&hl=en&ct=clnk&gl=us&client=firefox-a
Have you tried zeroing it out. How much space do you have to play with, etc.
Logged
http://www.infiltrated.net/mgz/puppylecter.jpg
H1t M0nk3y
Hero Member
Offline
Posts: 864
Re: Problem with a shellcode...
«
Reply #6 on:
May 13, 2010, 05:08:13 PM »
I know now that I can encode my shellcode using the msfencode or something similar. So that is fine now.
BUT, my problem is the my ESP register needs to get the value \x0A\xAF\xD8\x77 but I have a problem with \x0A... Can I encode a value in EIP?
I will check right now!
Logged
OSCP, GPEN, GWAPT, GSEC, CEH, CISSP
H1t M0nk3y
Hero Member
Offline
Posts: 864
Re: Problem with a shellcode...
«
Reply #7 on:
May 13, 2010, 05:13:02 PM »
I just checked and like I thought, it becomes too big!
When I "msfencode" \x0A\xAF\xD8\x77, I get:
"\xda\xc9\xd9\x74\x24\xf4\xbb\x6d\x18\xd7\xa6\x2b\xc9\x5a" +
"\xb1\x05\x83\xc2\x04\x31\x5a\x14\x03\x5a\x79\xfa\x22\xfa" +
"\xf9\xca\x8d\x5f\x81\x6b\x48\x3c\x09\x28\x6c\xe0\x91\x87" +
"\xbb\x12"
This can't fit in EIP.
I am so humble now...
But I will mak it work!!!
Logged
OSCP, GPEN, GWAPT, GSEC, CEH, CISSP
n1p
Jr. Member
Offline
Posts: 89
Re: Problem with a shellcode...
«
Reply #8 on:
May 13, 2010, 05:20:49 PM »
It is not meant to fit in EIP... That is your encoded shellcode, if you are looking for a valid return address i.e. start of your shellcode, it should not contain what can be considered bad characters - \x0d\x00\x0a.
Ensure EIP points to a NOP sled to your shellcode or directly into your shellcode. If you have correctly aligned your offsets, attempt to fill EIP with \xCC\xCC\xCC\xCC to get your debugger to break and show you whats going on.
Happy to take a look for you, but if it is course material, I doubt is allowed.
Logged
H1t M0nk3y
Hero Member
Offline
Posts: 864
Re: Problem with a shellcode...
«
Reply #9 on:
May 13, 2010, 05:50:44 PM »
Thanks guys, you are really helping me here!!
First, I could easily get the exploit on the internet, but I want to learn, so here I am!
Also, here is what I was successful doing:
1) I can set, let say, \x41\x41\x41\x41 in EIP (basicaly, I control EIP)
2) I successfully encoded my shellcode.
3) I have added a 16 bit long NOP sled at the beginning of ESP and my shellcode is right after.
4) I have verified that my shellcode in the memory of the program is identical to the one I have in my code. It is indeed identical.
I keep trying...
«
Last Edit: May 13, 2010, 05:53:27 PM by H1t M0nk3y
»
Logged
OSCP, GPEN, GWAPT, GSEC, CEH, CISSP
H1t M0nk3y
Hero Member
Offline
Posts: 864
Re: Problem with a shellcode...
«
Reply #10 on:
May 13, 2010, 06:04:16 PM »
I think I just solved my problem.
I found another JMP ESP instruction in users32.dll which doesn't contain any infamous characters. I am now able to reach the beginning of my shell code...
I can feel it, i is so close!!!
Logged
OSCP, GPEN, GWAPT, GSEC, CEH, CISSP
H1t M0nk3y
Hero Member
Offline
Posts: 864
Re: Problem with a shellcode...
«
Reply #11 on:
May 13, 2010, 06:16:41 PM »
I have got a bind shell from my
FIRST
exploit!!!!
Thanks n1p, sil, mambru and zeroflaw. I appreciate it!
As a note, I feel like, when I started going on racetrack with my racebike, the first time I touch my knee on the pavement in a curve. Brilliant!
I am so happy, and I am all alone tonight at home!
Ouff, I need a beer now!
Logged
OSCP, GPEN, GWAPT, GSEC, CEH, CISSP
mambru
Jr. Member
Offline
Posts: 98
Re: Problem with a shellcode...
«
Reply #12 on:
May 13, 2010, 10:23:40 PM »
No problem M0nk3y, I'm glad I was helpful in some way and you did it, I was on the same road a while ago (PWB course)
Logged
zeroflaw
Full Member
Offline
Posts: 208
Re: Problem with a shellcode...
«
Reply #13 on:
May 14, 2010, 01:51:56 AM »
You're welcome H1t M0nk3y! Glad to see you got it working. Good job
Logged
ZF
sil
Hero Member
Offline
Posts: 549
Re: Problem with a shellcode...
«
Reply #14 on:
May 14, 2010, 09:44:55 AM »
Quote from: H1t M0nk3y on May 13, 2010, 06:16:41 PM
I have got a bind shell from my
FIRST
exploit!!!!
NP and congrats. I'm going over a lot of advanced shellcoding tutorials and videos right now as well. My goal is repeatability across the board. Dino Zovi and Alex Sotirov have a class I'm waiting to attend called Assured Exploits. (
http://trailofbits.com/2010/02/25/assured-exploitation-training/
)
For example... Right now I have quite a few POC's and exploits for a variety of applications (I focus on the big boys, Oracle, IBM, etc. for obvious reasons
) Sometimes I submit work to CERT (they take forever even to get me my VRU's), sometimes I go to ZDI, sometimes IDefense, etc... Anyhow, I hate having something proven exploitable on say Windows 2003 Advanced Server, but not on say Win2008, Win7, etc.
I've been banging my head in reading especially for Win7 right now. E.g., I have one application, completely 'ownable' on everything EXCEPT Win7. I almost always get Access Violations on
? no matter what I do. A huge majority of things I find on say XP, I can replicate after a while on Vista, but on Win7 the same exploit almost always goes to kernelbase.dll so I've been trying to figure out why. It's a fun and sometimes frustrating experience.
n1p's document is definitely worth reading and again n1p if you read this, WinDBG rocks! So if you get one of those going let me know maybe I can learn more or even assist. H1t M0nk3y, I almost never suggest that anyone stray from what works for them however... I do have to state that WinDBG for debugging to me is more powerful. Not to mention the byakugan module would have found the right addresses for you:
Quote
What can you do with byakugan.dll ?
jutsu : set of tools to track buffers in memory, determining what is controlled at crash time, and discover valid return addresses
pattern_offset
mushishi : framework for anti-debugging detection and defeating anti-debugging techniques
tenketsu : vista heap emulator/visualizer.
identBuf / listBuf / rmBuf : find buffers (plain ascii, metasploit patterns, or data from file) in memory…
memDiff : compare data in memory with a pattern and mark the changes. This will help you determining whether e.g. shellcode has been changed/corrupted in memory, whether certain ‘bad characters’ need to be excluded from shellcode, etc
hunt
findReturn : search for the addresses that point to a usable function to return to.
searchOpcode : converts assembler instruction to opcode, AND it lists all executable opcode sequence addresses at the same time.
http://www.corelan.be:8800/index.php/2009/09/05/exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-basic-exploit-development/?nomobile
WinDBG rocks... Immunity's Debugger (as does Canvas) for those who use then has some cool stuff in it as well. I need to update Canvas :| The only time I fire up olly nowadays is for mapping :|
Logged
http://www.infiltrated.net/mgz/puppylecter.jpg
Pages: [
1
]
2
3
Go Up
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
EH-Net
-----------------------------
=> Calendar Of Events
===> ChicagoCon 2007
===> ChicagoCon 2008s
===> ChicagoCon 2008f
===> ChicagoCon 2009s
=> Ethical Hacktivism
=> News Items and General Discussion About EH-Net
===> Greetings
=> Special Events
-----------------------------
Ethical Hacking Discussions and Related Certifications
-----------------------------
=> General Certification
===> Networking
===> OS
===> Security
=> Compliance, Regulations & Standards
=> Control Systems
=> Cyber Warfare
=> Forensics
===> CCE / MCCE - (Master) Certified Computer Examiner
===> CHFI - Computer Hacking Forensic Investigator
===> EnCE - EnCase® Certified Examiner
===> GCFA - GIAC Certified Forensics Analyst
=> Hardware
=> Incident Response
===> CSIH - Computer Security Incident Handler
===> GCIH - GIAC Certified Incident Handler
=> Malware
===> Advisories
=> Mobile
=> Network Pen Testing
===> CEH - Certified Ethical Hacker
===> CPTC - Certified Penetration Testing Consultant
===> CPTE - Certified Penetration Testing Engineer
===> CSTA - Certified Security Testing Associate
===> eCPPT - eLearnSecurity Certified Professional Penetration Tester
===> ECSA - EC-Council Certified Security Analyst
===> GPEN - GIAC Certified Penetration Tester
===> OSCP - Offensive Security Certified Professional
=> Physical Security
=> Programming
=> Social Engineering
=> Web Applications
=> Wireless
===> CWNP Certs
===> GAWN - GIAC Assessing Wireless Networks
===> OSWP - Offensive Security Wireless Professional
=> Other
-----------------------------
Columns
-----------------------------
=> Editor-In-Chief
=> Andress
=> Gates
=> Haddix
=> Hadnagy
=> Heffner
=> Hoffman
=> Linn
=> RichM
=> Murray
=> J. Peltier
=> Weidman
=> Wilson
-----------------------------
Features
-----------------------------
=> /root
=> Book Reviews
=> Opinions
=> Skillz
===> Examples
===> May 06 - Star Hacks, Episode V: The Empire Hacks Back
===> July 06 - Hack Bill!
===> Sept 06 - Netcat in the Hat
===> Nov 06 - Hitch-Hackers Guide to the Galaxy
===> Dec 06 - A Christmas (Hacking) Story
===> Feb 07 - Charlottes Web Site
===> April 07 - Microsoft Office Space
===> June 07 - Serenity Hack
===> Oct 07 - Worst. Ethical. Hacker. Challenge. Ever.
===> Dec 07 - Frosty the Snow Crash
===> March 2008 - It Happened One Friday
===> Oct 2008 - Scooby Doo and the Crypto Caper
===> Dec 08 - Santa Claus Is Hacking to Town
===> Feb 2009 - Brady Bunch Boondoggle
===> July 2009 - Prison Break
===> October 2009 - SSHliders
===> December 2009 - Miracle on Thirty-Hack Street
===> December 2010 - The Nightmare Before Charlie Browns Christmas
-----------------------------
Resources
-----------------------------
=> Career Central
===> Looking For Work
===> Looking To Hire
=> Links to cool sites.
=> Mass Media
=> News from the Outside World
=> Tools
=> Tutorials
===> Tutorial Requests
Loading...
Exclusive Deal
SANSFIRE 2013
June 15 - 22
5% Off
w/ Code
:
EHN_5
SANS Deals 4 EH-Netters
5% OFF
Any
SANS Course
in Any Format!
Coupon Code:
EHN_5
Including
SANS Rocky Mountain 2013
&
SANS Boston 2013
Polls
Compared to this year, 2013 will be:
Great!
Better.
About the same.
Little worse.
FUBAR!
Recent Forum Topics
OSCP - Offensive Security Certified Professional
: OSCP exam scheduled
(6) by
gbhat
Incident Response
: LinkedIn Forensics
(0) by
AFENTIS_Forensics
General Certification
: Red Team/Blue Team
(1) by
ajohnson
OSCP - Offensive Security Certified Professional
: Class Scheduled 6/8 - Linux n00b
(6) by
Grendel
Career Central
: Starter cert?
(3) by
Grendel
Network Pen Testing
: Beginner Ethical Hacker
(1) by
m0wgli
General Certification
: CPT Practical Submission
(0) by
z28power4u
Web Applications
: Nessus and Nikto
(4) by
Seen
Tutorials
: Need guidance
(7) by
impelse
Malware
: EICAR?
(2) by
SephStorm
Network Pen Testing
: Cracking salted MD5 hash
(4) by
n37sh@rk
CEH - Certified Ethical Hacker
: Passed my C|EH
(3) by
n37sh@rk
Mass Media
: EC-council hacked, irony at his best?
(0) by
j0rDy
Web Applications
: SQL Injection into an INSERT statement.
(6) by
eyenit0
Network Pen Testing
: Solution for sipXtapi INVITE Message CSeq Field Header Remote Overflow
(1) by
m0wgli
Web Applications
: dns
(2) by
H1t M0nk3y
Other
: BSides Boston
(0) by
3xban
Career Central
: InfoSec in Central, FL
(2) by
tturner
Web Applications
: Web vulnerability scanner
(4) by
H1t M0nk3y
EH-Net News Feeds
Latest Additions
Privacy Notice
for TDCC & All Properties
© 2013 The Ethical Hacker Network
Joomla!
is Free Software released under the GNU/GPL License.