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 19 guests online
You are here:
Home
Ethical Hacking Discussions and Related Certifications
Malware
Encoding parts of a payload
EH-Net
May 25, 2013, 09:36:48 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
>
Malware
(Moderator:
don
) >
Encoding parts of a payload
Pages: [
1
]
2
Go Down
« previous
next »
Print
Author
Topic: Encoding parts of a payload (Read 3496 times)
0 Members and 1 Guest are viewing this topic.
H1t M0nk3y
Hero Member
Offline
Posts: 865
Encoding parts of a payload
«
on:
February 11, 2013, 10:28:37 AM »
Hi everyone,
When I use msfpayload to generate my payload (let's say, a Windows tcp bind shell), I always encode it with msfencode to remove null bytes (\x00) or any other characters (usually \x0a and \xff, sometimes more). I do this because these bytes would otherwise prevent the insertion of my payload in memory.
But what if my payload needs to be cut in two because I cannot put it all at the same memory location? For example, if my payload is 300 bytes long and I only have two spots of 200 bytes in memory? Should I carefully cut the payload (between two instructions) then encode each part separately, if they contain any invalid bytes? I would finally jump from the first part to the second one.
I haven't hit this problem yet, I was just "meditating" on the issue and couldn't get a good answer from Google.
Thanks
Logged
OSCP, GPEN, GWAPT, GSEC, CEH, CISSP
UNIX
Hero Member
Offline
Posts: 1235
Re: Encoding parts of a payload
«
Reply #1 on:
February 11, 2013, 10:36:54 AM »
Breaking the shellcode into several parts should work, but you have to verify where you separate it. If your first staged buffer is very limited in space you could also utilize an egg hunter to get eventually your shellcode executed.
Logged
H1t M0nk3y
Hero Member
Offline
Posts: 865
Re: Encoding parts of a payload
«
Reply #2 on:
February 11, 2013, 12:00:54 PM »
Yes, I guess it's better to search harder to find a bigger place in memory where you wouldn't have to break the payload.
But just for the sake of it, have you ever encode parts of your payload?
Logged
OSCP, GPEN, GWAPT, GSEC, CEH, CISSP
cd1zz
Recruiters
Hero Member
Offline
Posts: 561
Re: Encoding parts of a payload
«
Reply #3 on:
February 11, 2013, 04:49:14 PM »
I literally just had this last problem on the latest bug I posted. Just slapped together a blog post last night:
http://www.pwnag3.com/2013/02/actfax-raw-server-exploit.html
Bottom line, you can cut up the payload easily. However, if you mess with the payload being sent sometimes the memory layout/registers will be completely different and show you something better or worse. In my case, 4 bytes literally changed the entire structure...
Logged
OSCE | OSCP | GXPN | OSWP | CISSP
http://www.pwnag3.com
http://www.networkadminsecrets.com
ajohnson
Recruiters
Hero Member
Offline
Posts: 1060
aka dynamik
Re: Encoding parts of a payload
«
Reply #4 on:
February 11, 2013, 07:43:18 PM »
Quote from: cd1zz on February 11, 2013, 04:49:14 PM
I literally just had this last problem on the latest bug I posted. Just slapped together a blog post last night:
http://www.pwnag3.com/2013/02/actfax-raw-server-exploit.html
Bottom line, you can cut up the payload easily. However, if you mess with the payload being sent sometimes the memory layout/registers will be completely different and show you something better or worse. In my case, 4 bytes literally changed the entire structure...
How in the world do you have time for bug hunting?
Also, is that a standard fuzzing template? My coworker is currently playing around with Ability in the OSCP labs. He sent me his fuzzer for review, and it looked almost identical to yours, but with FTP commands.
Quote from: H1t M0nk3y on February 11, 2013, 10:28:37 AM
Hi everyone,
When I use msfpayload to generate my payload (let's say, a Windows tcp bind shell), I always encode it with msfencode to remove null bytes (\x00) or any other characters (usually \x0a and \xff, sometimes more). I do this because these bytes would otherwise prevent the insertion of my payload in memory.
But what if my payload needs to be cut in two because I cannot put it all at the same memory location? For example, if my payload is 300 bytes long and I only have two spots of 200 bytes in memory? Should I carefully cut the payload (between two instructions) then encode each part separately, if they contain any invalid bytes? I would finally jump from the first part to the second one.
I haven't hit this problem yet, I was just "meditating" on the issue and couldn't get a good answer from Google.
Thanks
Yea, that's going to be a pain because you're going to have to do a lot of that manually. As you noted, you can't just cut it in half and add a jump to the next portion. Not only will you need to encode each portion separately, you'd also need to correct any jumps and other offsets in the original shellcode. I'd try to get the exploit working without encoding first by binary pasting the shellcode into the appropriate places in a debugger, and then go back and dealing with encoding once the shellcode was functional. Just break it out into as many baby steps as you can.
It also depends on how big the gap is. There was a cool example in the Corelan course where the shellcode was broken by a double word, so a few instructions were added to the beginning of the shellcode to correct those four bytes. Something like that would certainly be a less involved solution, if possible.
Logged
WIP: GCFA |
www.infosiege.net
| @infosiege
The day you stop learning is the day you start becoming obsolete.
H1t M0nk3y
Hero Member
Offline
Posts: 865
Re: Encoding parts of a payload
«
Reply #5 on:
February 11, 2013, 07:45:03 PM »
Quote
However, if you mess with the payload being sent sometimes the memory layout/registers will be completely different and show you something better or worse.
That's a very good point. I just read your blog and I found it very well explained and easy to follow. Good job cd1zz!!
Quote
How in the world do you have time for bug hunting?
Did you guys know that cd1zz (Craig Freyman) has
19
exploits to his name in exploit-db? That's insane!!!
http://www.exploit-db.com/search/?action=search&filter_page=1&filter_description=&filter_exploit_text=&filter_author=Craig+Freyman&filter_platform=0&filter_type=0&filter_lang_id=0&filter_port=&filter_osvdb=&filter_cve=
«
Last Edit: February 11, 2013, 07:51:23 PM by H1t M0nk3y
»
Logged
OSCP, GPEN, GWAPT, GSEC, CEH, CISSP
cd1zz
Recruiters
Hero Member
Offline
Posts: 561
Re: Encoding parts of a payload
«
Reply #6 on:
February 11, 2013, 08:43:16 PM »
@ajohnson I've had it for so long, I completely forgot where it came from. This is it:
http://www.redteamsecure.com/labs/post/18/build-your-own-ftp-fuzzer
Editing the post now to reflect that!
Logged
OSCE | OSCP | GXPN | OSWP | CISSP
http://www.pwnag3.com
http://www.networkadminsecrets.com
UNIX
Hero Member
Offline
Posts: 1235
Re: Encoding parts of a payload
«
Reply #7 on:
February 12, 2013, 01:25:55 AM »
Nice write-up on the ActFax exploitation, cd1zz.
Logged
ajohnson
Recruiters
Hero Member
Offline
Posts: 1060
aka dynamik
Re: Encoding parts of a payload
«
Reply #8 on:
February 12, 2013, 03:51:47 AM »
Quote from: H1t M0nk3y on February 11, 2013, 07:45:03 PM
Did you guys know that cd1zz (Craig Freyman) has
19
exploits to his name in exploit-db? That's insane!!!
http://www.exploit-db.com/search/?action=search&filter_page=1&filter_description=&filter_exploit_text=&filter_author=Craig+Freyman&filter_platform=0&filter_type=0&filter_lang_id=0&filter_port=&filter_osvdb=&filter_cve=
Oh, I'm well aware of his... *wait for it* ...many exploits.
Sorry, I couldn't resist an awful pun
Seriously though, he was one of the few that was consistently finishing ahead of me in the Corelan course. He's a frustratingly sharp guy
Logged
WIP: GCFA |
www.infosiege.net
| @infosiege
The day you stop learning is the day you start becoming obsolete.
H1t M0nk3y
Hero Member
Offline
Posts: 865
Re: Encoding parts of a payload
«
Reply #9 on:
February 12, 2013, 07:01:48 AM »
cd1zz and ajohnson: Have you taken the Corelan course before or after OSCE?
It looks good, but 80% of the class seemed to be covered by the Cracking the Perimeter course...
Am I right?
Logged
OSCP, GPEN, GWAPT, GSEC, CEH, CISSP
cd1zz
Recruiters
Hero Member
Offline
Posts: 561
Re: Encoding parts of a payload
«
Reply #10 on:
February 12, 2013, 08:07:17 AM »
There is a lot of overlap and in many cases they compliment each other. We had a thread on here somewhere where we got into the nitty gritty. For example, OSCE covers no ROP exploitation but Corelan does. Corelan is 110% exploit dev. OSCE is 90%. If possible, do them both!!
ajohnson just knocked out OSCE and recently did Corelan, he might have a fresher perspective...
Logged
OSCE | OSCP | GXPN | OSWP | CISSP
http://www.pwnag3.com
http://www.networkadminsecrets.com
H1t M0nk3y
Hero Member
Offline
Posts: 865
Re: Encoding parts of a payload
«
Reply #11 on:
February 12, 2013, 08:55:30 AM »
OSCE is my goal right now, but I will keep a good eye on Corelan's tutorials at
https://www.corelan.be/index.php/category/security/exploit-writing-tutorials/
Thanks to your blog cd1zz, I now know about these things.
«
Last Edit: February 12, 2013, 09:04:13 AM by H1t M0nk3y
»
Logged
OSCP, GPEN, GWAPT, GSEC, CEH, CISSP
ajohnson
Recruiters
Hero Member
Offline
Posts: 1060
aka dynamik
Re: Encoding parts of a payload
«
Reply #12 on:
February 12, 2013, 12:14:19 PM »
I intend to do full write-ups on both, but my schedule's not going to clear up for the next few weeks.
In the interim, I think it's apples and oranges. Sure, they both cover exploit development, but there are huge differences in the tools, techniques, and approaches. As usual, OffSec focuses on doing everything manually and uses OllyDbg. The Corelan boot camp might as well be called "Exploit Development using Mona.py." You spend nearly the entire course in Immunity and working with Mona, from basic stack-based buffer overflows to egg hunters to ROP exploitation. The amount of annoying, tedious tasks that can be performed effortlessly with Mona is nothing short of amazing.
I think the Corelan course more accurately depicts how people who perform exploit development day-to-day go about their work. However, it's still important to understand what's going on behind-the-scenes and not rely on Mona as this magical tool that just works. Both courses compliment each other well, and I recommend doing both. Also, Peter is great to interact with, and being able to ask questions and bounce ideas around with him is a fantastic experience. He's going to work with you and not just tell you to try harder.
I actually took the Corelan course a couple of weeks before my OSCE exam, and one thing that did surprise me is that it really didn't help much, if at all, with the exam. I thought I would crush it for sure, but it ended up being the usual miserable experience with a miraculous pass in the last few hours. In fact, I actually ended up using a technique that wasn't covered in either course. I can't say more without spoiling it, but I posted my solution in the OffSec OSCE-only forums
Also be sure to check out the SecurityTube assembly and exploit development videos, as well as the tutorials over at The Grey Corner (thanks to UNIX for showing me those).
Logged
WIP: GCFA |
www.infosiege.net
| @infosiege
The day you stop learning is the day you start becoming obsolete.
H1t M0nk3y
Hero Member
Offline
Posts: 865
Re: Encoding parts of a payload
«
Reply #13 on:
February 12, 2013, 02:24:43 PM »
My list of things to read/review/do is getting longer and longer every day!!
Will I ever be able to challenge this exam?
Thanks ajohnson, very useful, as usual!
Logged
OSCP, GPEN, GWAPT, GSEC, CEH, CISSP
Dark_Knight
Sr. Member
Offline
Posts: 292
Re: Encoding parts of a payload
«
Reply #14 on:
February 24, 2013, 10:15:41 PM »
Quote from: cd1zz on February 11, 2013, 04:49:14 PM
I literally just had this last problem on the latest bug I posted. Just slapped together a blog post last night:
http://www.pwnag3.com/2013/02/actfax-raw-server-exploit.html
Bottom line, you can cut up the payload easily. However, if you mess with the payload being sent sometimes the memory layout/registers will be completely different and show you something better or worse. In my case, 4 bytes literally changed the entire structure...
I decided to throw my hat in the ring as well. Of course cd1zz has already done the heavy lifting and its not as sexy
http://sector876.blogspot.com/2013/02/hacking-actfax-raw-server.html
«
Last Edit: February 24, 2013, 10:26:14 PM by Dark_Knight
»
Logged
CEH, OSCP, GPEN, GWAPT, GCIA
http://sector876.blogspot.com
Pages: [
1
]
2
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
News Items and General Discussion About EH-Net
: Change is Coming to EH-Net!!
(30) by
don
Tools
: Symbolic Exploit Assistant project is looking for collaborators
(0) by
galapag0
Greetings
: Hi from the UK
(5) by
prats84
GCIH - GIAC Certified Incident Handler
: Passed my GCIH
(9) by
prats84
Network Pen Testing
: Want a challenge? Want a GXPN practice exam?
(0) by
ajohnson
GCIH - GIAC Certified Incident Handler
: GCIH Free Practice test attempt
(1) by
prats84
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.