progs/README
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Mon, 05 Oct 2015 20:42:11 +0100
changeset 395 60f64793266f
parent 393 cb308583d86c
child 400 f05368d007dd
permissions -rw-r--r--
added assembly programs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
392
4dff36e2bbc6 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 213
diff changeset
     1
Virtual-Box
4dff36e2bbc6 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 213
diff changeset
     2
4dff36e2bbc6 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 213
diff changeset
     3
Start "Linux Hacking"   password is "test"
4dff36e2bbc6 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 213
diff changeset
     4
393
cb308583d86c updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 392
diff changeset
     5
The programs are under 
392
4dff36e2bbc6 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 213
diff changeset
     6
395
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
     7
  cu$> app-material/progs
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
     8
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
     9
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    10
Programs can be updated using
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    11
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    12
  hg pull
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    13
  hg update
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    14
  hg revert --all
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    15
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    16
Emacs can be used to edit files
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    17
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    18
  emacs -nw ...file....     (is also an alias)
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    19
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    20
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    21
C0.c
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    22
====
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    23
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    24
Add the bigger string and the long is printed out differently.
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    25
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    26
C1.c
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    27
====
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    28
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    29
needs to be called using
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    30
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    31
  ./C1 `args1-good`
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    32
  ./C1 `args1-bad`
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    33
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    34
or in gdb using
392
4dff36e2bbc6 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 213
diff changeset
    35
395
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    36
  gdb --args ./C1 `args1-bad`
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    37
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    38
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    39
C2.c
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    40
====
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    41
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    42
called with
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    43
  
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    44
  ./args2-good | ./C2
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    45
  ./args2-bad  | ./C2
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    46
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    47
C3.c
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    48
====
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    49
(shell injection)
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    50
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    51
called with 
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    52
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    53
  ./C3
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    54
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    55
opens a new shell
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    56
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    57
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    58
C4.c
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    59
====
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    60
Format string attack
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    61
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    62
  ./C4 "%s"
60f64793266f added assembly programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 393
diff changeset
    63
  ./C4 `./args4`
392
4dff36e2bbc6 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 213
diff changeset
    64
4dff36e2bbc6 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 213
diff changeset
    65
4dff36e2bbc6 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 213
diff changeset
    66
4dff36e2bbc6 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 213
diff changeset
    67
------------------------------------
4dff36e2bbc6 updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 213
diff changeset
    68
213
9c2fa54c7c2d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 212
diff changeset
    69
to switch off address randomization
9c2fa54c7c2d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 212
diff changeset
    70
9c2fa54c7c2d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 212
diff changeset
    71
echo 0 | sudo tee /proc/sys/kernel/randomize_va_space
9c2fa54c7c2d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 212
diff changeset
    72
9c2fa54c7c2d updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 212
diff changeset
    73
212
1d2744383b7a added readme
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    74
1d2744383b7a added readme
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    75
C0.c
1d2744383b7a added readme
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    76
1d2744383b7a added readme
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    77
add to string 
1d2744383b7a added readme
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    78
 
1d2744383b7a added readme
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    79
  " \x15\xcd\x5b\x07"
1d2744383b7a added readme
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    80
1d2744383b7a added readme
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    81
to get
1d2744383b7a added readme
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    82
1d2744383b7a added readme
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    83
  foo("my string is too long !!!!! \x15\xcd\x5b\x07");