Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-8081-120121-

having fun executing shellcodes :)

Name: Anonymous 2012-03-21 11:43


#include <stdio.h>

unsigned char a[] = {
  0x7f, 0x45, 0x4c, 0x46, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00,
  0x30, 0x83, 0x04, 0x08, 0x34, 0x00, 0x00, 0x00, 0x28, 0x11, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x20, 0x00, 0x08, 0x00, 0x28, 0x00,
  0x1e, 0x00, 0x1b, 0x00, 0x06, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00,
  0x34, 0x80, 0x04, 0x08, 0x34, 0x80, 0x04, 0x08, 0x00, 0x01, 0x00, 0x00,
  0x00, 0x01, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
  0x03, 0x00, 0x00, 0x00, 0x34, 0x01, 0x00, 0x00, 0x34, 0x81, 0x04, 0x08,
  0x34, 0x81, 0x04, 0x08, 0x13, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00,
  0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x04, 0x08, 0x00, 0x80, 0x04, 0x08,
  0xd4, 0x04, 0x00, 0x00, 0xd4, 0x04, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
  0x00, 0x10, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x0f, 0x00, 0x00,
  0x0c, 0x9f, 0x04, 0x08, 0x0c, 0x9f, 0x04, 0x08, 0x08, 0x01, 0x00, 0x00,
  0x10, 0x01, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
  0x02, 0x00, 0x00, 0x00, 0x20, 0x0f, 0x00, 0x00, 0x20, 0x9f, 0x04, 0x08,
  0x20, 0x9f, 0x04, 0x08, 0xd0, 0x00, 0x00, 0x00, 0xd0, 0x00, 0x00, 0x00,
  0x06, 0x00,
  0x83, 0xec, 0x04, 0xa1, 0x0c, 0x9f, 0x04, 0x08, 0x83, 0xf8, 0xff, 0x74,
  0x13, 0xbb, 0x0c, 0x9f, 0x04, 0x08, 0x66, 0x90, 0x83, 0xeb, 0x04, 0xff,
  0xd0, 0x8b, 0x03, 0x83, 0xf8, 0xff, 0x75, 0xf4, 0x83, 0xc4, 0x04, 0x5b,
  0x5d, 0xc3, 0x90, 0x90, 0x55, 0x89, 0xe5, 0x53, 0x83, 0xec, 0x04, 0xe8,
  0x00, 0x00, 0x00, 0x00, 0x5b, 0x81, 0xc3, 0x4c, 0x1b, 0x00, 0x00, 0xe8,
  0xac, 0xfe, 0xff, 0xff, 0x59, 0x5b, 0xc9, 0xc3, 0x03, 0x00, 0x00, 0x00,
  0x01, 0x00, 0x02, 0x00, 0x77, 0x61, 0x73, 0x6e, 0x74, 0x20, 0x74, 0x68,
  0x61, 0x74, 0x20, 0x66, 0x75, 0x6e, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00
};

void main(){
    int (*func)();
      func = (int (*)()) a;
      (int)(*func)();
}

Name: Optimized 2012-03-21 12:00

int main() {
    return ((int (*)(void))(unsigned char[]){
  0x7f, 0x45, 0x4c, 0x46, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00,
  0x30, 0x83, 0x04, 0x08, 0x34, 0x00, 0x00, 0x00, 0x28, 0x11, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x20, 0x00, 0x08, 0x00, 0x28, 0x00,
  0x1e, 0x00, 0x1b, 0x00, 0x06, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00,
  0x34, 0x80, 0x04, 0x08, 0x34, 0x80, 0x04, 0x08, 0x00, 0x01, 0x00, 0x00,
  0x00, 0x01, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
  0x03, 0x00, 0x00, 0x00, 0x34, 0x01, 0x00, 0x00, 0x34, 0x81, 0x04, 0x08,
  0x34, 0x81, 0x04, 0x08, 0x13, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00,
  0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x04, 0x08, 0x00, 0x80, 0x04, 0x08,
  0xd4, 0x04, 0x00, 0x00, 0xd4, 0x04, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
  0x00, 0x10, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x0f, 0x00, 0x00,
  0x0c, 0x9f, 0x04, 0x08, 0x0c, 0x9f, 0x04, 0x08, 0x08, 0x01, 0x00, 0x00,
  0x10, 0x01, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
  0x02, 0x00, 0x00, 0x00, 0x20, 0x0f, 0x00, 0x00, 0x20, 0x9f, 0x04, 0x08,
  0x20, 0x9f, 0x04, 0x08, 0xd0, 0x00, 0x00, 0x00, 0xd0, 0x00, 0x00, 0x00,
  0x06, 0x00,
  0x83, 0xec, 0x04, 0xa1, 0x0c, 0x9f, 0x04, 0x08, 0x83, 0xf8, 0xff, 0x74,
  0x13, 0xbb, 0x0c, 0x9f, 0x04, 0x08, 0x66, 0x90, 0x83, 0xeb, 0x04, 0xff,
  0xd0, 0x8b, 0x03, 0x83, 0xf8, 0xff, 0x75, 0xf4, 0x83, 0xc4, 0x04, 0x5b,
  0x5d, 0xc3, 0x90, 0x90, 0x55, 0x89, 0xe5, 0x53, 0x83, 0xec, 0x04, 0xe8,
  0x00, 0x00, 0x00, 0x00, 0x5b, 0x81, 0xc3, 0x4c, 0x1b, 0x00, 0x00, 0xe8,
  0xac, 0xfe, 0xff, 0xff, 0x59, 0x5b, 0xc9, 0xc3, 0x03, 0x00, 0x00, 0x00,
  0x01, 0x00, 0x02, 0x00, 0x77, 0x61, 0x73, 0x6e, 0x74, 0x20, 0x74, 0x68,
  0x61, 0x74, 0x20, 0x66, 0x75, 0x6e, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00 })();
}

Name: id 2012-03-21 12:08

>>2
you're supposed to post your shellcode
and let others find what is happening

Name: Anonymous 2012-03-21 13:14

How is this shell code? I can tell it's an ELF executable because it starts with "\x7fELF".

Name: Anonymous 2012-03-21 13:15

>>3
implying I would be stupid enough to actually run these

Name: Anonymous 2012-03-21 13:19

The first one installed Gentoo on my machine and the second one blew my computer and half my dick vaporized.

Worst day ever.

Name: Anonymous 2012-03-21 13:58

Fuck off back to /g/ with your retarded shit.

Name: Anonymous 2012-03-21 14:41

>>5
well dont if you dont know how to run it safely
stupidity has nothing to do with it

>>4 well it aint elfcode either

people relax, enough with the negativity

Name: Anonymous 2012-03-21 14:58

>>8
And what about my dick? I think it's quite reasonable to be negative right now.

Name: Anonymous 2012-03-21 15:22

smell my negative dick

Name: VIPPER 2012-03-21 15:37

Shitty thread, did not bump.

Name: Anonymous 2012-03-21 15:38

>>9
?
no idea what you are talking about
but you can elaborate if you want
see if i can help you

Name: Anonymous 2012-03-21 15:40

>>1
void main()
Who would run any code from someone too dumb to realize that main returns an int?

Name: Anonymous 2012-03-21 15:42

>>13
still no idea, what you are trying to say
give me a hint at least

Name: Anonymous 2012-03-21 15:54

>>13
Someone who's smart enough. You disappointed me /prog/.

Name: Anonymous 2012-03-21 15:57

|*
srsly? you guys cant contribute some shellcode
or run that simple example in safe-mode, fuck me you are a disappointment

Name: Anonymous 2012-03-21 16:00

Segfaults on 3.2.10-3.fc16.x86_64

Name: Anonymous 2012-03-21 16:11

>>14,15
Son, the main function returns int, not void. Clang rejects your broken code.

Name: Anonymous 2012-03-21 16:11

This is stupid. Shellcode looks like this:

#!/bin/sh
echo "List of files:"
ls -lA
FILE_LIST="`ls *.html`"
echo FILE_LIST: ${FILE_LIST}
RESULT=""
for file in ${FILE_LIST}
do
FIRST_LINE=`head -2 ${file}`
RESULT=${RESULT}${FIRST_LINE}
done echo ${RESULT} | cat >FILE_HEADS
echo "'$RESULT'

Name: Anonymous 2012-03-21 16:16

>>18
/g/ is that way kid. Grown ups have a serious discussion.

Name: Anonymous 2012-03-21 16:21

Not valid C, didn't compile.

Also wouldn't execute since non-shit OS'es don't allow executable stacks.

Name: Anonymous 2012-03-21 16:21

>>18
broken code?

oh no, you are probably reading wrong
here >>1
if you dont know how to run it, well ask for help
i'll be glad to help you out

Name: Anonymous 2012-03-21 16:21

Undefined behavior.

Name: Anonymous 2012-03-21 16:22

>>22
Give us some hints please. Is it for x86? 32 or 64 bit?

Name: Anonymous 2012-03-21 16:23

>>21
here
>>22
took me a while to find what cause all this frustration

Name: Anonymous 2012-03-21 16:24

>>24
... Linux/Windows?

Name: Anonymous 2012-03-21 16:25

>>21
It compiles and executes. You realize that the shell code is not stored on stack?

Name: Anonymous 2012-03-21 16:33

>>20,22
Your troll ``shellcode'' doesn't even compile. If you change it to int main it causes a segfault because you're trying to run code from the data segment. It won't be able to exploit a buffer overflow even on its intended architecture/OS because it's full of embedded nulls. You should be glad your trolling got so many replies. Now go back to /g/.

Name: Anonymous 2012-03-21 16:35

>>27
It compiles and executes.
No it doesn't you stupid piece of shit. It's dependent on a shitty compiler and some shitty platform, this isn't cross-platform code.

Name: Anonymous 2012-03-21 16:37

>>28
ok lets take one problem at a time, see if i can help you
1)doesn't compile, try save the code with a .c extension its c code
if you haven't compiled a .c file before, use google there plenty of guides.

ok alert me when you done fixing that

Name: Anonymous 2012-03-21 16:38

>>29
see this
for further explanation
>>29

Name: Anonymous 2012-03-21 16:39

i meant this >>30

Name: Anonymous 2012-03-21 16:43

retard.exe has stopped working

Name: Anonymous 2012-03-21 16:43

>>30
It's not C code, C mandates that the return type of main is an int.

This is what my C compiler states:
error: return type of ‘main’ is not ‘int’.

Name: Anonymous 2012-03-21 16:46

Name: Anonymous 2012-03-21 16:47

So is this another one of these undefined behavior programs that requires a specific architecture/OS/compiler/compiler flags/no OS security?

Name: Anonymous 2012-03-21 16:47

>>29
cross-platform
dependent on a shitty compiler
doesn't even compile
exploit a buffer overflow
full of embedded nulls

Today /prog/ has shown its true face.

Name: Anonymous 2012-03-21 16:48

>>36
Except this time the faggot doesn't tell you what the specific architecture/OS/compiler/compiler flags are.

Name: Anonymous 2012-03-21 16:49

>>35
Listen you stupid piece of shit, this is taken from the C standard.

5.1.2.2.1 Program startup
The function called at program startup is named main. The implementation declares no prototype for this function. It shall be defined with a return type of int ...

In C, main has to return int, how the fuck don't you understand that? Your program isn't C and it's complete shit, now fuck off back to /g/.

Name: Anonymous 2012-03-21 16:50

>>33 wrong thread
>>36 no the arguments made about specific os,compilers etc are totally fictitious, by people who just lost their faith in /prog/
but dont worry the Cleansing has begun, thou shall be saved, my  fellow proggers

Name: Anonymous 2012-03-21 16:51

>>38
I think he actually believes that this is C, and that ELF is a portable format.

Name: Anonymous 2012-03-21 16:51

>>34
>>36
You fucking retards do you realize that it's some small homework that you can adjust to run if you were not fucking loosers complaining about totally not interesting details because that's the only thing you can do?

inb4 Oh yeah C standard is detail.
Grow up kids.

Name: Anonymous 2012-03-21 16:53

>>39
Your point? Are you trying to prove to use that you're so mentally disabled that you can't rewrite void to int or use the version in >>2?

Name: Anonymous 2012-03-21 16:53

>>39
touchy, touchy
here watch this, relax a bit
http://en.wikipedia.org/wiki/Anger_Management
and when you are ready and you have calmed down
take a look at this
http://en.wikipedia.org/wiki/C_%28programming_language%29
only when you are ready, remember learning should be fun!

Name: Anonymous 2012-03-21 16:53

>>42
You're not even trying anymore. Fuck off back to /g/, ``tray''.

Name: Anonymous 2012-03-21 16:54

>>44
You're not even trying anymore. Fuck off back to /g/, ``tray''.

Name: Anonymous 2012-03-21 16:56

>>43,44
Listen you stupid piece of shit, you can't cast object pointer types to function pointer types, so it isn't C.

Just fucking deal with you fucking moron, go back to /g/ with this shit.

Name: Anonymous 2012-03-21 16:58

>>43 again one step at the time. skipping steps wont get you anywhere

Name: Anonymous 2012-03-21 16:59

>>47
LOL, you can ... http://stackoverflow.com/a/9593583

back to /g/ lol

Name: Anonymous 2012-03-21 16:59

This isn't C.
error: ISO C forbids conversion of object pointer to function pointer type

Name: Anonymous 2012-03-21 17:00

>>49
Read the fucking standard you stupid piece of shit, it specifically mentions that it's illegal.

Name: Anonymous 2012-03-21 17:03

>>51
illegal
LOL ROFL, back to /g/ kid

Name: Anonymous 2012-03-21 17:04

>>40
no the arguments made about specific os,compilers etc are totally fictitious
So this compiles with C compilers? (no it doesn't, illegal conversion, main has wrong type, both illegal per the C standard)
So this works on both little endian and big endian machines? (no it doesn't)
So this works on something else than 32 bit machines? (no it doesn't)
So this works on something else than x86? (no it doesn't)
So this works on OS'es that mark data segments as non-executable? (no it doesn't)

Name: Anonymous 2012-03-21 17:05

>>49 no don't make fun of him, just because he's frustrated
doesn't mean we cant help him, his excessive use of words like shit and fuck, should only be a flag to this person's age and ethnicity, and i be damned if i give up to another keen but not able soul like him

Name: Anonymous 2012-03-21 17:05

>>52
Please cite from the C standard where it mentions otherwise.

Specifically try to look at section 6.3.2.3 of the ISO/IEC 9899:2011 standard, I think you'll be surprised.

Name: Anonymous 2012-03-21 17:07

>>55 lmao idiot who reads the rules like that its obviously allowed or else http://stackoverflow.com/a/9593583 wouldn't exist

LOL what an idiot go back to /g/ kid

Name: Anonymous 2012-03-21 17:07

>>55
Ok, here are some facts: You're
1) Interested in this thread
2) Not interested in figuring out what that machine code does
3) Interested in repeating excerpt from C standard that everybody knows and no one cares because GCC will compile it (and Clang too if you're not faggot)

Face it, you're just a looser.

Name: Anonymous 2012-03-21 17:08

Name: Anonymous 2012-03-21 17:10

>>1
Since this is undefined behavior (void main and trying to execute data as a function) and either fails to compile or segfaults with all compilers I've used, what OS, architecture, compiler, and compiler flags did you use to get this to run.

Name: Anonymous 2012-03-21 17:11

>>56,57
Same retard.

Name: Anonymous 2012-03-21 17:12

>>60
retard is a strong word
and no not same person

Name: Anonymous 2012-03-21 17:12

>>57

Interested in this thread
Not really.

Not interested in figuring out what that machine code does
It doesn't do anything, because it's not valid C code, you have to specify some compiler, platform and architecture before this becomes valid code.

Interested in repeating excerpt from C standard that everybody knows and no one cares because GCC will compile it (and Clang too if you're not faggot)
This is nonsensical, newer GCC and clang will compile this as GNU-C code. This still means that there are versions and flags you can't use, so you're dependent on a specific version of GCC and a specific version of clang, and then after you have specified those you are dependent on specific compiler flags.

Face it, you're just a looser.
First of all, it's called loser and not looser. I thought I would help you out since you're obviously mentally challenged. Second of all, ad hominem attacks will get you nowhere, you're wrong and you can either deal with it or go cry in a corner.

Name: Anonymous 2012-03-21 17:13

>>60
LOL idiot how can you say these are the same people
obviously not same person ROFL how can you believe that...

Name: Anonymous 2012-03-21 17:15

>>61
>>63
haha I'm laughing so much right now LOL how he thinks they are same person amazing...

Name: Anonymous 2012-03-21 17:16

>>62
OMG listen here are some more facts:
1) you are an idiot
2) you dont know what your talking about
3) you dont know how to compile code with GCC

Name: Anonymous 2012-03-21 17:16

i had no idea /prog/ was this dumb cant even compile and run C code LOL

Name: Anonymous 2012-03-21 17:17

>>62
you are just being too anal about things, without any particular
reason other than being a buster, i mean relax, if you don't want to participate then don't, but don't bring everyone down just because you are grumpy

Name: Anonymous 2012-03-21 17:18

That kind of shellcode won't work if the memory is marked as non executable. Use return to libc instead.

Name: Anonymous 2012-03-21 17:20

I like how he included stdio without using any part of it.

Name: Anonymous 2012-03-21 17:24

wow i ran this code this is so cool thanks OP
also cant believe that /prog/ isnt smart enough to run C code LOL ROFL haha they should really go back to /g/ LOL

Name: Anonymous 2012-03-21 17:25

>>57
Interested in repeating excerpt from C standard that everybody knows and no one cares because GCC will compile it (and Clang too if you're not faggot)
You can go back to /g/ now.

Name: Anonymous 2012-03-21 17:26

>>1,63-67,70,71
Same person.

Name: Anonymous 2012-03-21 17:28

When will people stop making shitty threads like this?

Name: Anonymous 2012-03-21 17:29

>>72 nope

Name: Anonymous 2012-03-21 17:30

>>72
You're probably not very far off, but I haven't posted in this thread before >>71. I don't think my post really looks like the ones you linked to either.

Name: Anonymous 2012-03-21 17:30

>>73
agreed c, and creating shellcode is way too advanced
for the average /prog/
try some python for god's sake

Name: Anonymous 2012-03-21 17:31

How do I disable DEP in Linux?

Name: Anonymous 2012-03-21 17:32

>>77
Just grab an older version.

Name: Anonymous 2012-03-21 17:34

If you post non-conforming code don't get butthurt when someone points it out, >>53 sums it up pretty well, and that doesn't even mention the ELF format.

Name: Anonymous 2012-03-21 17:36

>>79
ROFL LOL if you dont know how to run C code how are you on /prog/???

Name: Anonymous 2012-03-21 17:38

>>79
I hope you're trolling mate.

#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>

unsigned char a[] = {
  0x7f, 0x45, 0x4c, 0x46, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00,
  0x30, 0x83, 0x04, 0x08, 0x34, 0x00, 0x00, 0x00, 0x28, 0x11, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x20, 0x00, 0x08, 0x00, 0x28, 0x00,
  0x1e, 0x00, 0x1b, 0x00, 0x06, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00,
  0x34, 0x80, 0x04, 0x08, 0x34, 0x80, 0x04, 0x08, 0x00, 0x01, 0x00, 0x00,
  0x00, 0x01, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
  0x03, 0x00, 0x00, 0x00, 0x34, 0x01, 0x00, 0x00, 0x34, 0x81, 0x04, 0x08,
  0x34, 0x81, 0x04, 0x08, 0x13, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00,
  0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x04, 0x08, 0x00, 0x80, 0x04, 0x08,
  0xd4, 0x04, 0x00, 0x00, 0xd4, 0x04, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
  0x00, 0x10, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x0f, 0x00, 0x00,
  0x0c, 0x9f, 0x04, 0x08, 0x0c, 0x9f, 0x04, 0x08, 0x08, 0x01, 0x00, 0x00,
  0x10, 0x01, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
  0x02, 0x00, 0x00, 0x00, 0x20, 0x0f, 0x00, 0x00, 0x20, 0x9f, 0x04, 0x08,
  0x20, 0x9f, 0x04, 0x08, 0xd0, 0x00, 0x00, 0x00, 0xd0, 0x00, 0x00, 0x00,
  0x06, 0x00,
  0x83, 0xec, 0x04, 0xa1, 0x0c, 0x9f, 0x04, 0x08, 0x83, 0xf8, 0xff, 0x74,
  0x13, 0xbb, 0x0c, 0x9f, 0x04, 0x08, 0x66, 0x90, 0x83, 0xeb, 0x04, 0xff,
  0xd0, 0x8b, 0x03, 0x83, 0xf8, 0xff, 0x75, 0xf4, 0x83, 0xc4, 0x04, 0x5b,
  0x5d, 0xc3, 0x90, 0x90, 0x55, 0x89, 0xe5, 0x53, 0x83, 0xec, 0x04, 0xe8,
  0x00, 0x00, 0x00, 0x00, 0x5b, 0x81, 0xc3, 0x4c, 0x1b, 0x00, 0x00, 0xe8,
  0xac, 0xfe, 0xff, 0xff, 0x59, 0x5b, 0xc9, 0xc3, 0x03, 0x00, 0x00, 0x00,
  0x01, 0x00, 0x02, 0x00, 0x77, 0x61, 0x73, 0x6e, 0x74, 0x20, 0x74, 0x68,
  0x61, 0x74, 0x20, 0x66, 0x75, 0x6e, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00
};

unsigned short main(){
        if (mprotect(a, sizeof(a), PROT_READ | PROT_WRITE | PROT_EXEC) != 0)
                exit(1);
    int (*func)();
      func = (int (*)()) a;
      (int)(*func)();
      return 'c'; /* u mad? */
}

Prevented segfault.

Name: Anonymous 2012-03-21 17:40

>>81
OMG it just returned -1

Name: Anonymous 2012-03-21 17:44

>>1,3,8,14,16,20,22,25,27,30-32,35,40,42-44,48-49,52,54,56-57,61,63-67,70,74,76,80
You can stop samefagging, your program is stupid and you can take it back to /g/.

Name: Anonymous 2012-03-21 17:45

>>81
This isn't valid C, sys/mman.h is part of POSIX.

Name: Anonymous 2012-03-21 17:47

>>84
C allows for including other libraries.

Name: Anonymous 2012-03-21 17:49

>>85
Not if those libraries are platform dependent, then your code stops being C and starts being POSIX C.

You're dependent on compiling and executing this on a POSIX platform, which for instance won't work on Windows.

Name: Anonymous 2012-03-21 17:50

>>86
It will. Again, you must not be complete faggot.

Name: Anonymous 2012-03-21 17:52

>>87
No it won't sys/mman.h doesn't even exist on Windows, it's a POSIX header, not part of the C standard library.

Name: Anonymous 2012-03-21 17:53

Why don't you just specify which platform you are on, which architecture you're using, which version of GCC and which flags you are using? If you do all that then the behavior will probably have an actual meaning.

Name: Anonymous 2012-03-21 17:58

>>88
You see? You're complete faggot. It'll not work for you on Windows because you're complete faggot... Or great troll.

#include <unistd.h>
#include <signal.h>
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/mman.h>

unsigned char a[] = {
        0x7f, 0x45, 0x4c, 0x46, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00,
        0x30, 0x83, 0x04, 0x08, 0x34, 0x00, 0x00, 0x00, 0x28, 0x11, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x20, 0x00, 0x08, 0x00, 0x28, 0x00,
        0x1e, 0x00, 0x1b, 0x00, 0x06, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00,
        0x34, 0x80, 0x04, 0x08, 0x34, 0x80, 0x04, 0x08, 0x00, 0x01, 0x00, 0x00,
        0x00, 0x01, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
        0x03, 0x00, 0x00, 0x00, 0x34, 0x01, 0x00, 0x00, 0x34, 0x81, 0x04, 0x08,
        0x34, 0x81, 0x04, 0x08, 0x13, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00,
        0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x04, 0x08, 0x00, 0x80, 0x04, 0x08,
        0xd4, 0x04, 0x00, 0x00, 0xd4, 0x04, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
        0x00, 0x10, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x0f, 0x00, 0x00,
        0x0c, 0x9f, 0x04, 0x08, 0x0c, 0x9f, 0x04, 0x08, 0x08, 0x01, 0x00, 0x00,
        0x10, 0x01, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
        0x02, 0x00, 0x00, 0x00, 0x20, 0x0f, 0x00, 0x00, 0x20, 0x9f, 0x04, 0x08,
        0x20, 0x9f, 0x04, 0x08, 0xd0, 0x00, 0x00, 0x00, 0xd0, 0x00, 0x00, 0x00,
        0x06, 0x00,
        0x83, 0xec, 0x04, 0xa1, 0x0c, 0x9f, 0x04, 0x08, 0x83, 0xf8, 0xff, 0x74,
        0x13, 0xbb, 0x0c, 0x9f, 0x04, 0x08, 0x66, 0x90, 0x83, 0xeb, 0x04, 0xff,
        0xd0, 0x8b, 0x03, 0x83, 0xf8, 0xff, 0x75, 0xf4, 0x83, 0xc4, 0x04, 0x5b,
        0x5d, 0xc3, 0x90, 0x90, 0x55, 0x89, 0xe5, 0x53, 0x83, 0xec, 0x04, 0xe8,
        0x00, 0x00, 0x00, 0x00, 0x5b, 0x81, 0xc3, 0x4c, 0x1b, 0x00, 0x00, 0xe8,
        0xac, 0xfe, 0xff, 0xff, 0x59, 0x5b, 0xc9, 0xc3, 0x03, 0x00, 0x00, 0x00,
        0x01, 0x00, 0x02, 0x00, 0x77, 0x61, 0x73, 0x6e, 0x74, 0x20, 0x74, 0x68,
        0x61, 0x74, 0x20, 0x66, 0x75, 0x6e, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00
};

unsigned short main(){
        int pagesize;
        size_t len;

        pagesize = sysconf(_SC_PAGE_SIZE);
        if (pagesize == -1) {
                perror("pagesize");
                exit(1);
        }

        void * p = (unsigned char *) (((char)a % pagesize) * pagesize);

        if (mprotect(p, pagesize, PROT_READ | PROT_WRITE | PROT_EXEC) != 0) {
                perror("mprotect");
                exit(1);
        }
        int (*func)();
        func = (int (*)()) a;
        (int)(*func)();
        return 'c'; /* u mad? */
}


prints "mprotect: Cannot allocate memory"

Name: Anonymous 2012-03-21 17:59

>>90
Doesn't work on Windows, Windows isn't POSIX.

Name: Anonymous 2012-03-21 18:02

Guess what you stupid sack of shit I just did a grep of the entire ISO/IEC 9899:2011 standard for mprotect, no results. Same with unistd and sysconf, guess what? No results.

None of those are part of C.

Go read the fucking standard, it's part of POSIX so it won't work on non-POSIX platforms.

You can just keep on bringing in more platform dependent behavior, it will just make you look even more retarded than you already do.

Name: Anonymous 2012-03-21 18:02

Wait so this guy doesn't even know what the standard library is and what POSIX is?

Name: Anonymous 2012-03-21 18:03

Name: Anonymous 2012-03-21 18:04

>>92
is it really that hard to try and be polite?
you pretty much destroy any chance to be taken srsly

Name: Anonymous 2012-03-21 18:05

>>95
you pretty much destroy any chance to be taken srsly
By posting stupid shit like that you aren't taken seriously.

Just read the fucking standard you stupid piece of shit. Is it really that hard, or can't you afford it or something?

Name: Anonymous 2012-03-21 18:06

>>96
same here, whats bugging you mate?
whatever it is i'm pretty sure its not your fault

Name: Anonymous 2012-03-21 18:07

>>97
What's annoying me is that you keep displaying glaring ignorance when it comes to C, you have shown that you have no fucking clue what C means.

Read the standard, it will help you realize how fucking dumb you look right now.

Name: Anonymous 2012-03-21 18:07

This guy is like the reverse Kodak, he's just as persistent and moronic but hasn't actually read the standard.

Name: Anonymous 2012-03-21 18:08

>>96
here http://www.youtube.com/watch?v=GtkST5-ZFHw
just stop being angry at the world its not your fault

Name: Anonymous 2012-03-21 18:09

>>100
I'm not angry at all, I'm just laughing at you because you're so fucking dumb.

Name: Anonymous 2012-03-21 18:10

>>100
well its not your fault

Name: Anonymous 2012-03-21 18:11

>>101
its not your fault!

Name: Anonymous 2012-03-21 18:11

This is shitty platform, compiler, endian, word size, architecture dependent code.

Name: Anonymous 2012-03-21 18:11

>>103
I know it's not my fault, I blame your parents shitty genetic material and most likely shitty upbringing.

Name: Anonymous 2012-03-21 18:12

#include <unistd.h>
#include <signal.h>
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/mman.h>

unsigned char a[] = {
        0x7f, 0x45, 0x4c, 0x46, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00,
        0x30, 0x83, 0x04, 0x08, 0x34, 0x00, 0x00, 0x00, 0x28, 0x11, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x20, 0x00, 0x08, 0x00, 0x28, 0x00,
        0x1e, 0x00, 0x1b, 0x00, 0x06, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00,
        0x34, 0x80, 0x04, 0x08, 0x34, 0x80, 0x04, 0x08, 0x00, 0x01, 0x00, 0x00,
        0x00, 0x01, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
        0x03, 0x00, 0x00, 0x00, 0x34, 0x01, 0x00, 0x00, 0x34, 0x81, 0x04, 0x08,
        0x34, 0x81, 0x04, 0x08, 0x13, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00,
        0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x04, 0x08, 0x00, 0x80, 0x04, 0x08,
        0xd4, 0x04, 0x00, 0x00, 0xd4, 0x04, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
        0x00, 0x10, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x0f, 0x00, 0x00,
        0x0c, 0x9f, 0x04, 0x08, 0x0c, 0x9f, 0x04, 0x08, 0x08, 0x01, 0x00, 0x00,
        0x10, 0x01, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
        0x02, 0x00, 0x00, 0x00, 0x20, 0x0f, 0x00, 0x00, 0x20, 0x9f, 0x04, 0x08,
        0x20, 0x9f, 0x04, 0x08, 0xd0, 0x00, 0x00, 0x00, 0xd0, 0x00, 0x00, 0x00,
        0x06, 0x00,
        0x83, 0xec, 0x04, 0xa1, 0x0c, 0x9f, 0x04, 0x08, 0x83, 0xf8, 0xff, 0x74,
        0x13, 0xbb, 0x0c, 0x9f, 0x04, 0x08, 0x66, 0x90, 0x83, 0xeb, 0x04, 0xff,
        0xd0, 0x8b, 0x03, 0x83, 0xf8, 0xff, 0x75, 0xf4, 0x83, 0xc4, 0x04, 0x5b,
        0x5d, 0xc3, 0x90, 0x90, 0x55, 0x89, 0xe5, 0x53, 0x83, 0xec, 0x04, 0xe8,
        0x00, 0x00, 0x00, 0x00, 0x5b, 0x81, 0xc3, 0x4c, 0x1b, 0x00, 0x00, 0xe8,
        0xac, 0xfe, 0xff, 0xff, 0x59, 0x5b, 0xc9, 0xc3, 0x03, 0x00, 0x00, 0x00,
        0x01, 0x00, 0x02, 0x00, 0x77, 0x61, 0x73, 0x6e, 0x74, 0x20, 0x74, 0x68,
        0x61, 0x74, 0x20, 0x66, 0x75, 0x6e, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00
};

unsigned short main(){
        int pagesize;
        size_t len;
        void * p;

        pagesize = sysconf(_SC_PAGE_SIZE);
        if (pagesize == -1) {
                perror("pagesize");
                exit(1);
        }

        p = (void *) (( (unsigned long) a / pagesize) * pagesize);

        if (mprotect(p, pagesize, PROT_READ | PROT_WRITE | PROT_EXEC) != 0) {
                perror("mprotect");
                exit(1);
        }

        int (*func)();
        func = (int (*)()) a;
        (int)(*func)();
        return 'c'; /* u mad? */
}


mprotect passed, but it still segfaults line 59

Name: Anonymous 2012-03-21 18:13

>>105
its not your fault
i wont you to repeat after me ITS NOT MY FAULT!
let go!!! you can do it!!!

Name: Anonymous 2012-03-21 18:13

>>106
Doesn't compile for me.

Name: Anonymous 2012-03-21 18:14

>>107
I already said that it's not my fault, are you mentally challenged or something?

Name: Anonymous 2012-03-21 18:15

>>109
come one you can do it, you can shed a tear if you like
cause its NOT your FAULT!

Name: Anonymous 2012-03-21 18:16

CONFORMING TO
       POSIX.1-2001.

Name: Anonymous 2012-03-21 18:17

This guy must have escaped his special education tutor.

Name: Anonymous 2012-03-21 18:17

Disregard >>1-110
They suck cocks.

Name: Anonymous 2012-03-21 18:17

>>100
ah fuck you! i can pretty much see the face of Will in the face
of every shitposter

Name: Anonymous 2012-03-21 18:19

Protip: the guy who doesn't capitalize the start of sentences or his I's has been samefagging this whole thread

Name: Anonymous 2012-03-21 18:23

Name: Anonymous 2012-03-21 18:32

=> 0x0000000000600ae0 <+0>:     jg     0x600b27 <a+71>
   0x0000000000600ae2 <+2>:     rex.WR
   0x0000000000600ae3 <+3>:     rex.RX add DWORD PTR [rcx],r8d
   0x0000000000600ae6 <+6>:     add    DWORD PTR [rax],eax
   0x0000000000600ae8 <+8>:     add    BYTE PTR [rax],al
   0x0000000000600aea <+10>:    add    BYTE PTR [rax],al
   0x0000000000600aec <+12>:    add    BYTE PTR [rax],al
   0x0000000000600aee <+14>:    add    BYTE PTR [rax],al
   0x0000000000600af0 <+16>:    add    al,BYTE PTR [rax]
   0x0000000000600af2 <+18>:    add    eax,DWORD PTR [rax]
   0x0000000000600af4 <+20>:    add    DWORD PTR [rax],eax
   0x0000000000600af6 <+22>:    add    BYTE PTR [rax],al
   0x0000000000600af8 <+24>:    xor    BYTE PTR [rbx+0x340804],al
   0x0000000000600afe <+30>:    add    BYTE PTR [rax],al
   0x0000000000600b00 <+32>:    sub    BYTE PTR [rcx],dl
   0x0000000000600b02 <+34>:    add    BYTE PTR [rax],al
   0x0000000000600b04 <+36>:    add    BYTE PTR [rax],al
   0x0000000000600b06 <+38>:    add    BYTE PTR [rax],al
   0x0000000000600b08 <+40>:    xor    al,0x0
   0x0000000000600b0a <+42>:    and    BYTE PTR [rax],al
   0x0000000000600b0c <+44>:    or     BYTE PTR [rax],al
   0x0000000000600b0e <+46>:    sub    BYTE PTR [rax],al
   0x0000000000600b10 <+48>:    (bad)


Where am I?

Name: Anonymous 2012-03-21 18:33

So would this work on SPARC? Is assembly somehow magically portable all of a sudden?

Name: Anonymous 2012-03-21 18:35

>>118
Yes

Name: Anonymous 2012-03-21 18:35

>>118 of course it is :-)

Name: Anonymous 2012-03-21 18:37

>>117
Nobody cares about your shitty x86.

Name: Anonymous 2012-03-21 18:38

>>121
Why?

Name: Anonymous 2012-03-21 18:38

OP it segfaults on

0x0000000000600ae2 <+2>:     rex.WR

(3rd instruction in your "shellcode"). Why? I'm on 64 bit.

Name: Anonymous 2012-03-21 18:40

>>123
LOL idiot you dont know how to run portable C code? ROFL how do you even browse /prog/ go back to /g/ kid

Name: Anonymous 2012-03-21 18:41

>>123
Basically every one of those instructions are illegal on anything but x86.

Name: Anonymous 2012-03-21 18:42

>>125
I'm on Sandy Bridge.

Name: Anonymous 2012-03-21 19:59

What kind of CPU uses 0000 to mean ADD? A shitty Jew CPU.

Don't change these.
Name: Email:
Entire Thread Thread List