Skip to content

Instantly share code, notes, and snippets.

@rodolfobandeira
Last active November 13, 2017 00:55
Show Gist options
  • Save rodolfobandeira/37bfcc6be294aec8fc6210e145dff15c to your computer and use it in GitHub Desktop.
Save rodolfobandeira/37bfcc6be294aec8fc6210e145dff15c to your computer and use it in GitHub Desktop.
openbsd_pledge_test_ioctl: file format elf64-x86-64
Disassembly of section .init:
0000000000000350 <__init>:
350: 48 83 ec 08 sub $0x8,%rsp
354: e8 07 01 00 00 callq 460 <__register_frame_info+0x10>
359: 48 83 c4 08 add $0x8,%rsp
35d: c3 retq
Disassembly of section .plt:
0000000000000360 <printf@plt-0x10>:
360: ff 35 3a 0c 20 00 pushq 2100282(%rip) # 200fa0 <_GLOBAL_OFFSET_TABLE_+0x8>
366: ff 25 3c 0c 20 00 jmpq *2100284(%rip) # 200fa8 <_GLOBAL_OFFSET_TABLE_+0x10>
36c: cc int3
36d: cc int3
36e: cc int3
36f: cc int3
0000000000000370 <printf@plt>:
370: ff 25 3a 0c 20 00 jmpq *2100282(%rip) # 200fb0 <_GLOBAL_OFFSET_TABLE_+0x18>
376: 68 00 00 00 00 pushq $0x0
37b: e9 e0 ff ff ff jmpq 360 <__init+0x10>
0000000000000380 <getuid@plt>:
380: ff 25 32 0c 20 00 jmpq *2100274(%rip) # 200fb8 <_GLOBAL_OFFSET_TABLE_+0x20>
386: 68 01 00 00 00 pushq $0x1
38b: e9 d0 ff ff ff jmpq 360 <__init+0x10>
0000000000000390 <pledge@plt>:
390: ff 25 2a 0c 20 00 jmpq *2100266(%rip) # 200fc0 <_GLOBAL_OFFSET_TABLE_+0x28>
396: 68 02 00 00 00 pushq $0x2
39b: e9 c0 ff ff ff jmpq 360 <__init+0x10>
00000000000003a0 <err@plt>:
3a0: ff 25 22 0c 20 00 jmpq *2100258(%rip) # 200fc8 <_GLOBAL_OFFSET_TABLE_+0x30>
3a6: 68 03 00 00 00 pushq $0x3
3ab: e9 b0 ff ff ff jmpq 360 <__init+0x10>
00000000000003b0 <atexit@plt>:
3b0: ff 25 1a 0c 20 00 jmpq *2100250(%rip) # 200fd0 <_GLOBAL_OFFSET_TABLE_+0x38>
3b6: 68 04 00 00 00 pushq $0x4
3bb: e9 a0 ff ff ff jmpq 360 <__init+0x10>
00000000000003c0 <_csu_finish@plt>:
3c0: ff 25 12 0c 20 00 jmpq *2100242(%rip) # 200fd8 <_GLOBAL_OFFSET_TABLE_+0x40>
3c6: 68 05 00 00 00 pushq $0x5
3cb: e9 90 ff ff ff jmpq 360 <__init+0x10>
00000000000003d0 <exit@plt>:
3d0: ff 25 0a 0c 20 00 jmpq *2100234(%rip) # 200fe0 <_GLOBAL_OFFSET_TABLE_+0x48>
3d6: 68 06 00 00 00 pushq $0x6
3db: e9 80 ff ff ff jmpq 360 <__init+0x10>
00000000000003e0 <_Jv_RegisterClasses@plt>:
3e0: ff 25 02 0c 20 00 jmpq *2100226(%rip) # 200fe8 <_GLOBAL_OFFSET_TABLE_+0x50>
3e6: 68 07 00 00 00 pushq $0x7
3eb: e9 70 ff ff ff jmpq 360 <__init+0x10>
Disassembly of section .text:
00000000000003f0 <__start>:
3f0: 48 89 d1 mov %rdx,%rcx
3f3: 48 8b 3c 24 mov (%rsp),%rdi
3f7: 48 8d 54 fc 10 lea 0x10(%rsp,%rdi,8),%rdx
3fc: 48 8d 74 24 08 lea 0x8(%rsp),%rsi
401: 48 83 ec 08 sub $0x8,%rsp
405: 48 83 e4 f0 and $0xfffffffffffffff0,%rsp
409: 48 83 c4 08 add $0x8,%rsp
40d: eb 01 jmp 410 <__start+0x20>
40f: cc int3
410: 55 push %rbp
411: 48 89 e5 mov %rsp,%rbp
414: 41 57 push %r15
416: 41 56 push %r14
418: 53 push %rbx
419: 50 push %rax
41a: 48 89 f3 mov %rsi,%rbx
41d: 41 89 fe mov %edi,%r14d
420: 48 89 df mov %rbx,%rdi
423: 48 89 d6 mov %rdx,%rsi
426: 48 89 ca mov %rcx,%rdx
429: e8 92 ff ff ff callq 3c0 <_csu_finish@plt>
42e: 49 89 c7 mov %rax,%r15
431: e8 1a ff ff ff callq 350 <__init>
436: 49 8b 17 mov (%r15),%rdx
439: 44 89 f7 mov %r14d,%edi
43c: 48 89 de mov %rbx,%rsi
43f: e8 14 01 00 00 callq 558 <main>
444: 89 c7 mov %eax,%edi
446: e8 85 ff ff ff callq 3d0 <exit@plt>
44b: cc int3
44c: cc int3
44d: cc int3
44e: cc int3
44f: cc int3
0000000000000450 <__register_frame_info>:
450: 55 push %rbp
451: 48 89 e5 mov %rsp,%rbp
454: 5d pop %rbp
455: c3 retq
456: cc int3
457: cc int3
458: cc int3
459: cc int3
45a: cc int3
45b: cc int3
45c: cc int3
45d: cc int3
45e: cc int3
45f: cc int3
460: 8a 05 a2 0b 20 00 mov 2100130(%rip),%al # 201008 <__bss_start+0x8>
466: 84 c0 test %al,%al
468: 74 01 je 46b <__register_frame_info+0x1b>
46a: c3 retq
46b: 55 push %rbp
46c: 48 89 e5 mov %rsp,%rbp
46f: 41 56 push %r14
471: 53 push %rbx
472: c6 05 8f 0b 20 00 01 movb $0x1,2100111(%rip) # 201008 <__bss_start+0x8>
479: 48 8d 3d 80 06 10 00 lea 1050240(%rip),%rdi # 100b00 <__fini+0x100550>
480: 48 8d 35 89 0b 20 00 lea 2100105(%rip),%rsi # 201010 <__bss_start+0x10>
487: e8 c4 ff ff ff callq 450 <__register_frame_info>
48c: 48 83 3d 9c 09 20 00 cmpq $0x0,2099612(%rip) # 200e30 <__guard_local+0x8>
493: 00
494: 74 16 je 4ac <__register_frame_info+0x5c>
496: 48 83 3d 5a 0b 20 00 cmpq $0x0,2100058(%rip) # 200ff8 <_GLOBAL_OFFSET_TABLE_+0x60>
49d: 00
49e: 74 0c je 4ac <__register_frame_info+0x5c>
4a0: 48 8d 3d 89 09 20 00 lea 2099593(%rip),%rdi # 200e30 <__guard_local+0x8>
4a7: e8 34 ff ff ff callq 3e0 <_Jv_RegisterClasses@plt>
4ac: 4c 8b 35 c5 0a 20 00 mov 2099909(%rip),%r14 # 200f78 <_DYNAMIC+0x140>
4b3: 49 83 fe ff cmp $0xffffffffffffffff,%r14
4b7: 75 23 jne 4dc <__register_frame_info+0x8c>
4b9: 49 c7 c6 ff ff ff ff mov $0xffffffffffffffff,%r14
4c0: 48 8d 05 b1 0a 20 00 lea 2099889(%rip),%rax # 200f78 <_DYNAMIC+0x140>
4c7: eb 07 jmp 4d0 <__register_frame_info+0x80>
4c9: cc int3
4ca: cc int3
4cb: cc int3
4cc: cc int3
4cd: cc int3
4ce: cc int3
4cf: cc int3
4d0: 4a 83 7c f0 10 00 cmpq $0x0,0x10(%rax,%r14,8)
4d6: 4d 8d 76 01 lea 0x1(%r14),%r14
4da: 75 f4 jne 4d0 <__register_frame_info+0x80>
4dc: 4d 85 f6 test %r14,%r14
4df: 74 1a je 4fb <__register_frame_info+0xab>
4e1: 48 8d 05 90 0a 20 00 lea 2099856(%rip),%rax # 200f78 <_DYNAMIC+0x140>
4e8: 4a 8d 1c f0 lea (%rax,%r14,8),%rbx
4ec: eb 02 jmp 4f0 <__register_frame_info+0xa0>
4ee: cc int3
4ef: cc int3
4f0: ff 13 callq *(%rbx)
4f2: 48 8d 5b f8 lea 0xfffffffffffffff8(%rbx),%rbx
4f6: 49 ff ce dec %r14
4f9: 75 f5 jne 4f0 <__register_frame_info+0xa0>
4fb: 48 8b 3d ee 0a 20 00 mov 2099950(%rip),%rdi # 200ff0 <_GLOBAL_OFFSET_TABLE_+0x58>
502: 5b pop %rbx
503: 41 5e pop %r14
505: 5d pop %rbp
506: e9 a5 fe ff ff jmpq 3b0 <atexit@plt>
50b: cc int3
50c: cc int3
50d: cc int3
50e: cc int3
50f: cc int3
510: 55 push %rbp
511: 48 89 e5 mov %rsp,%rbp
514: 53 push %rbx
515: 50 push %rax
516: 8a 05 34 0b 20 00 mov 2100020(%rip),%al # 201050 <__bss_start+0x50>
51c: 84 c0 test %al,%al
51e: 75 2e jne 54e <__register_frame_info+0xfe>
520: c6 05 29 0b 20 00 01 movb $0x1,2100009(%rip) # 201050 <__bss_start+0x50>
527: 48 8b 05 62 0a 20 00 mov 2099810(%rip),%rax # 200f90 <_DYNAMIC+0x158>
52e: 48 85 c0 test %rax,%rax
531: 74 1b je 54e <__register_frame_info+0xfe>
533: 48 8d 1d 5e 0a 20 00 lea 2099806(%rip),%rbx # 200f98 <_GLOBAL_OFFSET_TABLE_>
53a: eb 04 jmp 540 <__register_frame_info+0xf0>
53c: cc int3
53d: cc int3
53e: cc int3
53f: cc int3
540: ff d0 callq *%rax
542: 48 8b 03 mov (%rbx),%rax
545: 48 83 c3 08 add $0x8,%rbx
549: 48 85 c0 test %rax,%rax
54c: 75 f2 jne 540 <__register_frame_info+0xf0>
54e: 48 83 c4 08 add $0x8,%rsp
552: 5b pop %rbx
553: 5d pop %rbp
554: c3 retq
555: cc int3
556: cc int3
557: cc int3
0000000000000558 <main>:
558: 55 push %rbp
559: 48 89 e5 mov %rsp,%rbp
55c: 48 83 ec 10 sub $0x10,%rsp
560: be 00 00 00 00 mov $0x0,%esi
565: 48 8d 3d fc 04 10 00 lea 1049852(%rip),%rdi # 100a68 <__fini+0x1004b8>
56c: e8 1f fe ff ff callq 390 <pledge@plt>
571: 83 f8 ff cmp $0xffffffffffffffff,%eax
574: 75 16 jne 58c <main+0x34>
576: 48 8d 35 f1 04 10 00 lea 1049841(%rip),%rsi # 100a6e <__fini+0x1004be>
57d: bf 01 00 00 00 mov $0x1,%edi
582: b8 00 00 00 00 mov $0x0,%eax
587: e8 14 fe ff ff callq 3a0 <err@plt>
58c: e8 ef fd ff ff callq 380 <getuid@plt>
591: 89 c6 mov %eax,%esi
593: 48 8d 3d ea 04 10 00 lea 1049834(%rip),%rdi # 100a84 <__fini+0x1004d4>
59a: b8 00 00 00 00 mov $0x0,%eax
59f: e8 cc fd ff ff callq 370 <printf@plt>
5a4: b8 00 00 00 00 mov $0x0,%eax
5a9: c9 leaveq
5aa: c3 retq
5ab: cc int3
Disassembly of section .fini:
00000000000005b0 <__fini>:
5b0: 48 83 ec 08 sub $0x8,%rsp
5b4: e8 57 ff ff ff callq 510 <__register_frame_info+0xc0>
5b9: 48 83 c4 08 add $0x8,%rsp
5bd: c3 retq
@rodolfobandeira
Copy link
Author

Original file:

#include <stdio.h>
#include <unistd.h>
#include <err.h>

int main() {

//     if (-1 == pledge("stdio", NULL)) {
    if (-1 == pledge("ioctl", NULL)) {
        err(1, "pledge error detected");
    }

    printf("uuid: %d \n", getuid());
    return 0;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment