0% found this document useful (0 votes)
274 views

SLAE Student Slides PDF

Uploaded by

camldt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
274 views

SLAE Student Slides PDF

Uploaded by

camldt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 263

SecurityTube

 Linux  Assembly  Expert  


(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  

Course  Introduc4on  

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  

hLp://SecurityTube-­‐Training.com    

©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  

hLp://securitytube-­‐training.com/online-­‐courses/securitytube-­‐linux-­‐assembly-­‐expert/    

©SecurityTube.net  
Course  Syllabus  –  Assembly  Basics  

©SecurityTube.net  
ApplicaSon  to  Infosec  

©SecurityTube.net  
Registered  Students  Benefit  

©SecurityTube.net  
Future  Courses  

•  64-­‐bit  Assembly  on  Linux  

•  32/64-­‐bit  Assembly  on  Windows  

•  ARM  Assembly  

©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE)  

hLp://www.securitytube.net    
   

Vivek  Ramachandran  
Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Module  1:  32-­‐Bit  ASM  on  Linux  

1.  What  is  Assembly  Language?  

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  

hLp://SecurityTube-­‐Training.com    

©SecurityTube.net  
What  is  Assembly  Language?  

•  Low-­‐level  programming  language  

•  Communicate  with  microprocessor  

•  Specific  to  the  processor  family    

•  An  almost  one-­‐one  correspondence  with  


machine  code  

©SecurityTube.net  
I  only  speak  binary!  

010101010111110101101010101010101  
111010101101011010101010101011010  
010101010111101000011110101010101  

©SecurityTube.net  
Humans  cannot  speak  binary  

010101010111110101101010101010101  
111010101101011010101010101011010  
010101010111101000011110101010101  

©SecurityTube.net  
Assembly  Language  

Assembly  Language   Machine  Language  

mov  eax,  ebx   Assembler  +  Linker   010110100101  


xor      eax,  eax   111010101010  
add    eax,  0xff   101010101010  
Translator  

©SecurityTube.net  
CorrelaSon  with  HLLs  

hLp://www.tenouk.com/ModuleW_files/ccompilerlinker001.png    
©SecurityTube.net  
Different  Processors  –  Different  Assembly  
Language  
•  Intel  

•  ARM  

•  MIPS  

©SecurityTube.net  
Intel  Architecture  

•  IA-­‐32  

•  IA-­‐64  

©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert32  

•  IA-­‐32  Assembly  on  the  Linux  OS  


 
•  Future  courses:  
–  IA-­‐64  on  Linux  
–  IA-­‐32  on  Windows    
–  IA-­‐64  on  Windows  
–  ARM  Assembly  

©SecurityTube.net  
Why  IA-­‐32?  

•  Large  number  of  machines  out  there  sSll  


running  IA-­‐32  

•  Logical  progression  to  IA-­‐64  

•  Shellcoding,  Encoders,  Decoders,  Packers  etc.  


implementaSon  difference  

©SecurityTube.net  
Exercise  1.1:  Lab  Setup    

•  Ubuntu  12.04  LTS  32-­‐bit  EdiSon  

•  Installed  in  Virtualbox  

 
Please  Register  for  this  course  to  receive  the  soluSon  video  for  
this  exercise.  
hLp://SecurityTube-­‐Training.com    
 
©SecurityTube.net  
Exercise  1.2:  Understanding  your  CPU  
•  Find  CPU  details  on  the  Ubuntu  System  

•  How  do  you  know  if  you  are  on  a  32/64  bit  
CPU?  

•  How  do  you  know  your  CPUs  addiSonal  


capabiliSes  such  as  FPU,  MMX,  SSE,  SSE2  etc.    
 
Please  Register  for  this  course  to  receive  the  soluSon  video  for  
this  exercise.  
hLp://SecurityTube-­‐Training.com    
©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
Module  1:  32-­‐Bit  ASM  on  Linux  

Exercise  1.1  
Topic:  What  is  Assembly  Language?  
Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  

hLp://SecurityTube-­‐Training.com    

©SecurityTube.net  
Exercise  1.1:  Lab  Setup    

•  Ubuntu  12.04  LTS  32-­‐bit  EdiSon  

•  Installed  in  Virtualbox  

©SecurityTube.net  
Ubuntu  

•  32-­‐bit  Ubuntu  Desktop  EdiSon  12.10  used  for  


the  course  

hLp://www.ubuntu.com/download/desktop    

•  Install  Virtualbox  

hLps://www.virtualbox.org/    

©SecurityTube.net  
InstallaSon  

•  Nasm  

•  Code  files:  
–  SLAE-­‐Code.zip  

©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
Module  1:  32-­‐Bit  ASM  on  Linux  

Exercise  1.2  
Topic:  What  is  Assembly  Language?  
Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  

hLp://SecurityTube-­‐Training.com    

©SecurityTube.net  
Exercise  1.2:  Understanding  your  CPU  
•  Find  CPU  details  on  the  Ubuntu  System  

•  How  do  you  know  if  you  are  on  a  32/64  bit  
CPU?  

•  How  do  you  know  your  CPUs  addiSonal  


capabiliSes  such  as  FPU,  MMX,  SSE,  SSE2  etc.    

©SecurityTube.net  
Find  CPU  Details  

©SecurityTube.net  
/proc/cpuinfo  

©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Module  1:  32-­‐Bit  ASM  on  Linux  

2.  IA-­‐32  Architecture  
Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  

hLp://SecurityTube-­‐Training.com    

©SecurityTube.net  
System  OrganizaSon  Basics  

CPU  

System  Bus   Memory  

I/O  Devices  

©SecurityTube.net  
CPU  

Registers  

Control  Unit   CPU  


Execu4on  Unit  
Flags  

• Control  Unit  –  Retrieve  /  Decode  instrucSons,  Retrieve  /  Store  data  in  


memory  

• Execu4on  Unit  –  Actual  execuSon  of  instrucSon  happens  here  

• Registers  -­‐    Internal  memory  locaSons  used  as  “variables”  

• Flags  –    Used  to  indicate  various  “event”  when  execuSon  is  happening  

©SecurityTube.net  
IA-­‐32  Registers  (Logical  Diagram)  

General  Purpose   Segment  Registers   Flags,  EIP  


Registers  

FloaSng  Point  Unit   MMX   XMM  


Registers   Registers   Registers  

©SecurityTube.net  
General  Purpose  Registers  
AX  

EAX   AH   AL  
31   15   7   0  

BX  

EBX   BH   BL  
31   15   7   0  
CX  

ECX   CH   CL  
31   15   7   0  
DX  

EDX   DH   DL  
31   15   7   0  
©SecurityTube.net  
General  Purpose  Registers  
SP  

ESP  
31   15   0  
BP  

EBP  
31   15   0  
SI  

ESI  
31   15   0  
DI  

EDI  
31   15   0  
©SecurityTube.net  
GPR  Common  FuncSonality  
EAX   Accumulator  Register  –  used  for  storing  operands  and  result  data      

EBX   Base  Register  –  Pointer  to  Data      

ECX   Counter  Register  –  Loop  operaSons      

EDX   Data  Register  –  I/O  Pointer      

ESI   EDI   Data  Pointer  Registers  for  memory  operaSons        

ESP   Stack  Pointer  Register  

EBP   Stack  Data  Pointer  Register  


©SecurityTube.net  
Segment  Registers  

CS   Code  

DS   Data  

SS   Stack  

ES   Data  

FS   Data  

GS   Data  

15   0  

Usage  Depends  on  memory  model  –  Flat  or  Segmented?  

©SecurityTube.net  
EFLAGS  Register  

Ref:  Intel  manual  for  IA-­‐32   ©SecurityTube.net  


EIP  

EIP  
31   0  

•  InstrucSon  Pointer    
•  Holy  grail  for  Shellcoding,  Exploit  Research  
etc.  

©SecurityTube.net  
FloaSng  Point  Unit  (FPU)  or  x87  

ST(0)  to  ST(7)  

Reference:  Intel  Manual  


©SecurityTube.net  
SIMD  

•  Single  InstrucSon  MulSple  Data  

•  Extensions  
–  MMX  
–  SSE  
–  SSE2  
–  SSE3  

•  Uses  MMX  and  XMM  Registers  


©SecurityTube.net  
MMX  
ST(0)   MM0  

ST(1)   MM1  

ST(2)   MM2  

ST(3)   MM3  

ST(4)   MM4  

ST(5)   MM5  

ST(6)   MM6  

ST(7)   MM7  

79   63   0  
©SecurityTube.net  
XMM  
XMM0  

XMM1  

XMM2  

XMM3  

XMM4  

XMM5  

XMM6  

XMM7  

127   0  
©SecurityTube.net  
Exercise  1.2.1:  Lab  Setup    

 
•  Inspect  the  General  Purpose,  Segment,  
EFLAGS,  FPU,  MMX,  XMM  etc.  registers  on  
your  Ubuntu  system  

 
Please  Register  for  this  course  to  receive  the  soluSon  video  for  
this  exercise.  
hLp://SecurityTube-­‐Training.com    
 
©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
Exercise  1.2.1:  Lab  Setup    

 
•  Inspect  the  General  Purpose,  Segment,  
EFLAGS,  FPU,  MMX,  XMM  etc.  registers  on  
your  Ubuntu  system  

©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Module  1:  32-­‐Bit  ASM  on  Linux  

3.  CPU  Modes  and  Memory  Management  


Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  

hLp://SecurityTube-­‐Training.com    

©SecurityTube.net  
CPU  Modes  for  IA-­‐32  
•  Real  Mode  
–  At  power  up  or  reset  
–  Can  only  access  1  MB  memory  
–  No  memory  protecSon  
–  Privilege  Levels  (Kernel  vs  User  space)  not  possible  

•  Protected  Mode  
–  Up  to  4GB  memory  
–  memory  protecSon  /  privilege  level  /  mulS-­‐tasking  
–  Supports  Virtual-­‐8086  mode  

•  System  Management  Mode  


–  Used  for  power  management  tasks  

©SecurityTube.net  
Memory  Models    

Source:  Intel  manuals   ©SecurityTube.net  


Linux:  CPU  Mode  and  Memory  Model  

•  32-­‐Bit  Linux  uses:  


–  Protected  Mode  
–  Flat  Memory  model  
–  4GB  Addressable  space    =>    232    
–  Memory  ProtecSon  
–  Privilege  Levels  of  Code  
–  Segment  registers  point  to  segment  descriptors  
•  GDT  /  LDT  /  IDT  (Global  /  Local  /  Interrupt  )  

©SecurityTube.net  
Virtual  Memory  Model  

Kernel  Space  
(1  GB)  

User  Space  
(3  GB)  

©SecurityTube.net  
0XFFFFFFFF  
Kernel  Space  
0xC0000000  

Stack   FuncSon  Args  +  Local  Vars  

Shared  Libs  +  Mappings  

Heap   Dynamic  Memory  

BSS   UniniSalized  Data  

Data   IniSalized  Data  

Text   Program  Code  


0x08048000  
0x00000000  

©SecurityTube.net  
View  Process  OrganizaSon  

•  /Proc  
–  /proc/pid/maps  

•  pmap  

•  ALach  and  view  using  GDB  

©SecurityTube.net  
cat  /proc/pid/maps  

©SecurityTube.net  
What  does  all  this  mean?  

Start  and  End  Address   Offset  in  file   Inode  number   File  Path  
of  the  secSon   for  memory  mapped  
files.  0  otherwise.    

Major  –  Minor  device  number  


of  device  from  where  the  file  
was  loaded  

Permissions  on  the  secSon:  


•  r  =  readable  
•  w  =  writable  
•  x  =  executable  
•  p  =  private  not  shared  
•  s  =  shared  
©SecurityTube.net  
Process  Map  within  GDB  

©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Module  1:  32-­‐Bit  ASM  on  Linux  

4.  Hello  World  
Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  

hLp://SecurityTube-­‐Training.com    

©SecurityTube.net  
IA-­‐32  InstrucSon  Set  

•  General  Purpose  InstrucSons  

•  x87  FPU  InstrucSons  

•  MMX  /  SSE  /  SSE2/  SSE3  /  SSE4  InstrucSons  

•  Other  InstrucSon  Set  extensions  

©SecurityTube.net  
Programming  in  Assembly  

•  NASM  +  LD  for  assembling  and  linking  

•  Executable  in  ELF  format  

NASM  DocumentaSon:  
 
hLp://nasm.us/    

©SecurityTube.net  
Hello  World!  
Entry  Point  of  Program?   _start:  

Print  to  Screen  


TEXT  SecSon  

Exit  Gracefully!  

Hello  World!   DATA  SecSon  

©SecurityTube.net  
Why  System  Calls?  

•  Leverage  OS  for  tasks  

•  Imagine  if  you  had  to  write  code  from  scratch  to:  
–  write  to  disk    
–  print  on  screen  
–  …  

•  System  Calls  provide  a  simple  interface  for  user  


space  programs  to  the  Kernel  

©SecurityTube.net  
How  do  System  calls  work?  

User  Space  Program  


Interrupt  Handlers  Table  
….  
….  
….  
int  0x80   System  Call  RouSnes  
System  Call  
Handler  

©SecurityTube.net  
IA-­‐32  Mechanism  to  invoke  System  Call  

•  int  0x80  

•  SYSENTER  

Modern  implementaSons  using  VDSO  


[Virtual  Dynamic  Shared  Object]  
 
hLp://arScles.manugarg.com/systemcallinlinux2_6.html    

©SecurityTube.net  
Where  are  these  system  calls  defined?  

©SecurityTube.net  
write()  

©SecurityTube.net  
exit  

©SecurityTube.net  
Invoking  System  Call  with  0x80  
EAX   System  Call  Number   Return  Value  in  EAX  

EBX      1st  Argument  

ECX   2nd  Argument  

EDX   3rd  Argument  

ESI   4th  Argument  

EDI   5th  Argument  

©SecurityTube.net  
Calling  Write  

EAX  =  system  call  number     ECX  =  Pointer  to  “Hello  World”    

EDX  =  Length  of  “Hello  World”    


EBX  =  STDOUT  

©SecurityTube.net  
Calling  Exit  

EBX  =  Status  Code  

EAX  =  system  call  number    

©SecurityTube.net  
Exercise  1.4.1:  GDB  
 
•  Use  GDB  to  step  through  the  Hello  World  
program  and  observe:  
–  CPU  Registers  
–  Memory  LocaSon  
–  …  
 
Please  Register  for  this  course  to  receive  the  soluSon  video  for  
this  exercise.  
hLp://SecurityTube-­‐Training.com    
 
©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
Exercise  1.4.1:  GDB  
 
•  Use  GDB  to  step  through  the  Hello  World  
program  and  observe:  
–  CPU  Registers  
–  Memory  LocaSon  
–  …  
 
Please  Register  for  this  course  to  receive  the  soluSon  video  for  
this  exercise.  
hLp://SecurityTube-­‐Training.com    
 
©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Module  1:  32-­‐Bit  ASM  on  Linux  

5.  Data  Types  
Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  

hLp://SecurityTube-­‐Training.com    

©SecurityTube.net  
Fundamental  Data  Types  

•  Byte  –  8  bits  

•  Word  –  16  bits  

•  Double  Word  –  32  bits    

•  Quad  Word  –  64  bits    

•  Double  Quad  Word  –  128  bits    

Source:  IA-­‐32  Manual  


©SecurityTube.net  
Signed  and  Unsigned  
Unsigned  Double  Word  

31   0  

Signed  Double  Word  

Sign  Bit  

31   30   0  
Source:  IA-­‐32  Manual  

©SecurityTube.net  
NASM  …  

•  Case  SensiSve  syntax  

•  Accessing  memory  reference  with  []  


–  message  db  0xAA,  0xBB,  0xCC,  0xDD  
–  mov  eax,  message  ß  moves  address  into  eax  
–  move  eax,  [message]  ß  moves  value  into  eax  

©SecurityTube.net  
Defining  IniSalized  Data  in  NASM  

Source:  NASM  Manual  Pg.  30  

©SecurityTube.net  
Declare  UniniSalized  Data  

Source:  NASM  Manual  Pg.  30  

©SecurityTube.net  
Special  Tokens  

•  $  -­‐  evaluates  to  the  current  line  

•  $$  -­‐  evaluates  to  the  beginning  of  current  


secSon  

Source:  NASM  Manual  Pg.  37  

©SecurityTube.net  
EQU  and  TIMES  

Data:  

InstrucSon:  

©SecurityTube.net  
IA-­‐32  uses  LiLle  Endian  format  

Low  Memory  

High  Memory  

Source:  
30   Wikipedia  hLp://en.wikipedia.org/wiki/Endianness    

©SecurityTube.net  
GDB    

hLp://www.securitytube.net/tags/sgde    

©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Module  1:  32-­‐Bit  ASM  on  Linux  

6.  Moving  Data  
Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  

hLp://SecurityTube-­‐Training.com    

©SecurityTube.net  
InstrucSon  

Label   InstrucSon   Operand  

•  Register  
•  Memory  
•  Immediate  

©SecurityTube.net  
MOV  

•  Most  common  instrucSon  in  ASM  

•  Allowed  DirecSons  
–  Between  Registers  
–  Memory  to  Register  and  Register  to  Memory  
–  Immediate  Data  to  Register  
–  Immediate  Data  to  Memory  

©SecurityTube.net  
LEA  

•  Load  EffecSve  Address  –  load  pointer  values    

•  LEA  EAX,  [label]    

©SecurityTube.net  
XCHG  

•  Exchanges  (swaps)  Values  

•  XCHG  Register,  Register  

•  XCHG  Register,  Memory  

©SecurityTube.net  
Stack  

•  Used  by  processes  and  threads  to  store  


temporary  data  
–  local  variables    
–  return  addresses    

•  Stack  is  a  Last-­‐in-­‐First-­‐out  (LIFO)  data  


structure    

©SecurityTube.net  
Stack  is  a  LIFO  
High  Memory  

0xAAAAAAAA  
PUSH  –  Pushes  a  value  onto  
the  Stack  
0x10203040  
POP  –  Removes  the  topmost  
ESP   value  from  the  Stack  
0xA0203040  
ESP  –  Should  point  to  top  of  
Stack  

Low  Memory  

©SecurityTube.net  
Exercise  1.6.1  

•  Use  the  PUSH  /  POP  /  …  stack  instrucSons  in  


your  program  

•  Use  GDB  to  examine  the  stack  using  ESP  and  


track  the  changes  as  the  instrucSons  run  
 
Please  Register  for  this  course  to  receive  the  soluSon  video  for  
this  exercise.  
hLp://SecurityTube-­‐Training.com    
 
©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Exercise  1.6.1  

•  Use  the  PUSH  /  POP  /  …  stack  instrucSons  in  


your  program  

•  Use  GDB  to  examine  the  stack  using  ESP  and  


track  the  changes  as  the  instrucSons  run  
 
Please  Register  for  this  course  to  receive  the  soluSon  video  for  
this  exercise.  
hLp://SecurityTube-­‐Training.com    
 
©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Module  1:  32-­‐Bit  ASM  on  Linux  

7.  Arithme4c  Instruc4ons  
Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  

hLp://SecurityTube-­‐Training.com    

©SecurityTube.net  
EFLAGS  Register  

Ref:  Intel  manual  for  IA-­‐32   ©SecurityTube.net  


ArithmeSc  InstrucSons  

•  ADD  desSnaSon,  source    

•  ADC  desSnaSon,  source  (plus  carry  flag)  

•  SUB  and  SBB  

•  INC  and  DEC  

©SecurityTube.net  
Exercise  1.7.1  

•  MulSply  and  Divide  InstrucSons  

•  GDB  to  trace  execuSon  and  register  values  

 
Please  Register  for  this  course  to  receive  the  soluSon  video  for  
this  exercise.  
hLp://SecurityTube-­‐Training.com    
 
©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Exercise  1.7.1  

•  MulSply  and  Divide  InstrucSons  

•  GDB  to  trace  execuSon  and  register  values  

©SecurityTube.net  
Unsigned  MulSply    (MUL)  

AL   AX   EAX  

*   *   *  
r/m8   r/m16   r/m32  

AX   DX   AX   EDX   EAX  

OF  =  1  and  CF  =  1  if  upper  half  of  result  is  non-­‐zero  


©SecurityTube.net  
Unsigned  Divide  (DIV)  

AX   DX   AX   EDX   EAX  

÷   ÷   ÷  
r/m8   r/m16   r/m32  

Q   AL   Q   AX   Q   EAX  

R   AH   R   DX   R   EDX  

©SecurityTube.net  
Signed  ArithmeSc  

•  IMUL  

•  IDIV  

©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Module  1:  32-­‐Bit  ASM  on  Linux  

8.  Logical  Instruc4ons    
Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  

hLp://SecurityTube-­‐Training.com    

©SecurityTube.net  
Logical  OperaSons  

•  AND  r/m  ,    r/m/imm    (8,  16,  32  bits)  

•  OR  

•  XOR  

•  NOT  

©SecurityTube.net  
Bitwise  OperaSon  

1   1  

AND  

1   0  

|  |    

1   0  

©SecurityTube.net  
Other  InstrucSons  

•  SAR  –  Shiy  ArithmeSc  Right  

•  SHR    -­‐  Shiy  Logical  Right    

•  ROR  

•  ROL  

•  …  

©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Module  1:  32-­‐Bit  ASM  on  Linux  

9.  Control  Instruc4ons  
Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  

hLp://SecurityTube-­‐Training.com    

©SecurityTube.net  
Control  InstrucSons  

•  Controls  the  flow  of  the  program  

•  Based  on  “events”  e.g.  calculaSon  led  to  0  

•  Uses  flags  to  determine  decision  

•  Branching  
–  UncondiSonal  –  JMP  
–  CondiSonal  -­‐  Jxx  

©SecurityTube.net  
JMP  

•  UncondiSonal  
–  compare  it  with  the  GOTO  statement  in  C  

•  Types:  
–  Near  Jump:    Current  Code  Segment  
•  Short:  -­‐128  to  +127  from  current  posiSon  
–  Far  Jump:  In  another  Segment  

©SecurityTube.net  
Jxx  

•  Jxx  –  CondiSonal    
–  JZ,  JNZ,  JA,  JAE,  JC,  JNC    etc.    
–  uses  flags  

•  Cannot  be  used  for  Far  Jumps    


–  JNZ  label1  
–  JMP  Far_Label  
–  lable1:    

•  Intel  Manual  is  the  best  reference  

©SecurityTube.net  
Exercise  1.9.1  

•  InvesSgate  the  use  of  the  following  


instrucSons  –  LOOP,  LOOPZ,  LOOPNZ  etc.    

•  Use  GDB  to  trace  through  the  execuSon    

 
Please  Register  for  this  course  to  receive  the  soluSon  video  for  
this  exercise.  
hLp://SecurityTube-­‐Training.com    
 
©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Exercise  1.9.1  

•  InvesSgate  the  use  of  the  following  


instrucSons  –  LOOP,  LOOPE,  LOOPNE  etc.    

•  Use  GDB  to  trace  through  the  execuSon    

©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Module  1:  32-­‐Bit  ASM  on  Linux  

10.  Procedures  
Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  

hLp://SecurityTube-­‐Training.com    

©SecurityTube.net  
Procedure  

•  Set  of  operaSons  grouped  together  

•  Called  oyen  from  different  places  in  the  code  

•  CALL  Procedure_Name  

•  In  NASM  procedures  are  defined  using  Labels  

©SecurityTube.net  
Format  of  a  Procedure  

ProcedureName:    
 
 …  code…  
 …  code  …  
 …  code  …  
 RET  
 
 
©SecurityTube.net  
Arguments  to  a  Procedure  

•  Passed  via  Registers  

•  Passed  on  the  stack  

•  Passed  as  data  structures  in  memory  


referenced  by  registers  /  or  on  stack  

©SecurityTube.net  
Saving  and  Restoring  State  

•  Saving  /  Restoring  Registers  


–  PUSHAD  /  POPAD  

•  Saving  /  Restoring  Flags  


–  PUSHFD  /  POPFD  

•  Saving  /  Restoring  
–  ENTER  /  LEAVE  +  RET    

©SecurityTube.net  
Exercise  1.10.1  

•  Write  a  program  which  saves  registers  and  


flags  before  calling  a  procedure  
–  it  should  also  save  /  restore  the  frame  pointer    

 
Please  Register  for  this  course  to  receive  the  soluSon  video  for  
this  exercise.  
hLp://SecurityTube-­‐Training.com    
 
©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Exercise  1.10.1  

•  Write  a  program  which  saves  registers  and  


flags  before  calling  a  procedure  
–  it  should  also  save  /  restore  the  frame  pointer    

©SecurityTube.net  
Prologue  and  Epilogue  

•  Wikipedia:  
 
hLps://en.wikipedia.org/wiki/
FuncSon_prologue    
 
•  Space  is  reserved  for  storing  local  variables  

©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Module  1:  32-­‐Bit  ASM  on  Linux  

11.  Strings  
Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  

hLp://SecurityTube-­‐Training.com    

©SecurityTube.net  
String  InstrucSons  

•  MOVS      (  MOVS  /  MOVSW  /  MOVSD  )  

•  CMPS      -­‐  Compares    

•  SCAS    -­‐  Subtracts    

•  LODS    -­‐  Loads    


 
ESI  and  EDI  registers  are  typically  used  with  DF  

©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Module  1:  32-­‐Bit  ASM  on  Linux  

11.  Libc  and  NASM  


Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  

hLp://SecurityTube-­‐Training.com    

©SecurityTube.net  
Syscalls  are  good  but  …  

•  Too  low  level  at  Smes    

•  Standard  C  Library  –  libc  has  tons  of  useful  


funcSons  

•  Calling  Libc  funcSons  from  Assembly  

©SecurityTube.net  
Things  to  Remember  

•  Define  all  libc  funcSons  you  want  use  with  extern  

•  All  arguments  in  reverse  order  on  stack  


–  CALL  funcSon(a,b,c,d)  
–  push  d,  push  c,  push  b,  push  a  

•  Adjust  the  stack  ayer  calling  libc  funcSons  

•  Link  with  GCC  rather  than  LD  –  use  main  instead  


of  _start  

©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Module  2:  IntroducSon  to  Shellcoding  

1.  Shellcoding  Basics  
Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  

hLp://SecurityTube-­‐Training.com    

©SecurityTube.net  
What  is  Shellcode?  

•  Machine  code  with  a  specific  purpose  


–  spawn  a  local  shell  
–  Bind  to  port  and  spawn  shell  
–  create  a  new  account  

•  Can  be  executed  by  the  CPU  directly  –  no  


further  assembling    /  linking  or  separate  
compiling  required  

©SecurityTube.net  
How  is  Shellcode  delivered?  

•  Part  of  an  exploit  


–  Size  of  shellcode  important  (smaller  size  =  beLer)  
–  Bad  characters  a  concern  
•  0x00  most  common  one  

•  Added  into  an  executable    


–  run  as  separate  thread  
–  replace  executable  funcSonality    
–  Size  of  shellcode  not  a  concern  

©SecurityTube.net  
Shellcode  Resources  

•  hLp://www.shell-­‐storm.org/    

•  hLp://exploit-­‐db.com    

•  hLp://www.projectshellcode.com/    

©SecurityTube.net  
TesSng  Shellcode  

©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Module  2:  IntroducSon  to  Shellcoding  

2.  Exit  Shellcode  
Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  

hLp://SecurityTube-­‐Training.com    

©SecurityTube.net  
Exit  Shellcode  

•  Use  of  EAX  and  EBX  registers  with  the  syscall  


number  and  exit  code  leads  to  0x00  in  
shellcode  

•  Change  instrucSons  to  avoid  0x00  

•  Change  instrucSon  to  make  shellcode  more  


compact  

©SecurityTube.net  
Objdump  to  Shellcode  

•  Command  line  FU  

•  hLp://www.commandlinefu.com/commands/
view/6051/get-­‐all-­‐shellcode-­‐on-­‐binary-­‐file-­‐
from-­‐objdump    

©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Module  2:  IntroducSon  to  Shellcoding  

3.  HelloWorld  Shellcode  using  JMP-­‐CALL-­‐POP  


Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  

hLp://SecurityTube-­‐Training.com    

©SecurityTube.net  
Modifying  Hello  World  

•  Replace  all  0x00  opcode  instrucSons  

•  No  hardcoded  addresses  
–  dynamically  figure  out  address  of  “Hello  World”  
string    

©SecurityTube.net  
JMP-­‐CALL-­‐POP  
JMP  short  Call_shellcode:  
 
shellcode:  
                                     pop  ecx    
   ….  
   …  
   …  
 
Call_shellcode:  
 
           call  shellcode:  
           HelloWorld  db  “Hello  World!”  
 

©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Module  2:  IntroducSon  to  Shellcoding  

4.  HelloWorld  Shellcode  using  Stack  


Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  

hLp://SecurityTube-­‐Training.com    

©SecurityTube.net  
Using  the  Stack  

•  PUSH  the  value  of  the  “Hello  World”  string  on  


the  stack  

•  Get  a  reference  using  ESP  

•  String  needs  to  be  pushed  in  reverse  as  stack  


grows  from  High  to  Low  memory  

©SecurityTube.net  
Stack  grows  from  High  memory  to  Low  
memory    

High  Memory  

H   E   L   L   O   W   O   R   L   D   \n   0x00  

Low  Memory  

©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Module  2:  IntroducSon  to  Shellcoding  

5.  Execve  Shellcode  JMP-­‐CALL-­‐POP  Method  


Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  

hLp://SecurityTube-­‐Training.com    

©SecurityTube.net  
Execute  a  new  program  

•  execute  a  new  program  from  within  the  


shellcode  

•  “/bin/bash”  to  get  a  shell  

•  common  technique  to  get  a  command  prompt  


from  an  exploited  process  

©SecurityTube.net  
Execve  

/bin/bash,  0x0   0x00000000   Address  of  /bin/bash,  0x00000000    


EBX   EDX   ECX  

We  cannot  have  NULLs  in  the  Shellcode  

©SecurityTube.net  
Approach  
IniSal  String  

/bin/bash   A   BBBB   CCCC  

1 Use  JMP-­‐CALL-­‐POP  to  find  the  address  of  the  string  

2 Convert  “A”  to  0x0    

3 Convert  “BBBB”  to  address  of  “/bin/bash”  

4 Convert  “CCCC”  to    0x00000000  

ESI   /bin/bash   0x0   Addr   0x00000000  

©SecurityTube.net  
Loading  the  Registers  
ESI   /bin/bash   0x0   Addr   0x00000000  

©SecurityTube.net  
Is  there  a  need  for  exit()  

•  execve  does  not  return  if  successful    

•  there  is  no  need  for  exit()  to  be  called  

©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Module  2:  IntroducSon  to  Shellcoding  

6.  Execve  Shellcode  Stack  Method  


Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  

hLp://SecurityTube-­‐Training.com    

©SecurityTube.net  
Stack  Push  
Low  Memory   High  Memory  

ADDR   0x00000000   ////bin/bash   0x00000000  

ECX   EDX   EBX  

©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Module  2:  IntroducSon  to  Shellcoding  

7.  XOR  Encoder  and  Decoder  


Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  

hLp://SecurityTube-­‐Training.com    

©SecurityTube.net  
XOR  
A   B   A  xor  B  
0   0   0  
1   1   0  
1   0   1  
0   1   1  

InteresSng:          (  A  xor  B  )    xor  B  =  A    

©SecurityTube.net  
What  does  this  mean  for  us?  

•  Select  an  encoder  byte  e.g.  0xAA  

•  XOR  every  byte  of  Shellcode  with  0xAA  

•  Write  a  decoder  stub  which  will  XOR  the  encoded  


shellcode  bytes  with  0xAA  and  recover  original  
shellcode  

•  Stub  then  passes  control  to  decoded  shellcode  

©SecurityTube.net  
Too  much  text  can  kill  a  concept  J  
Original  Shellcode  

0x12   0xab   0xac   0x01   ………  

XOR  

0xaa   0xaa   0xaa   0xaa   ………  

||  
Decode  Shellcode  
XOR  Decoder  Stub   0xb8   0x01   0x06   0xab   ………  

Original  Shellcode  
XOR  Decoder  Stub   0x12   0xab   0xac   0x01   ………  

©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Module  2:  IntroducSon  to  Shellcoding  

8.  Using  Metasploit’s  Encoders  


Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  

hLp://SecurityTube-­‐Training.com    

©SecurityTube.net  
Metasploit  Payloads  

©SecurityTube.net  
Metasploit  Encoders  

©SecurityTube.net  
Leverage  Metasploit  

•  Create  our  own  Shellcode  

•  Use  Msfencode  to  encode  it  


–  use  encoded  shellcode  
–  dump  into  binary  and  execute  

©SecurityTube.net  
AV  and  IDS  Evasion  

•  Almost  all  Encoders  in  Metasploit  are  well  


known  and  documented  

•  Might  not  be  useful  to  create  evasion    


–  Shikata_ga_nai  works  at  Smes  

•  Need  for  custom  encoders  

©SecurityTube.net  
Custom  Encoder  

•  Easy  to  write  a  custom  encoder  and  bypass  AV  


etc.  Sll  the  Sme  the  technique  is  not  disclosed    

•  Very  difficult  to  write  an  encoder  which  has  a  


public  technique  and  evade  AV  

•  Encoder  Stub  is  the  one  which  is  generally  


fingerprinted  

©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Module  2:  IntroducSon  to  Shellcoding  

9.  Simple  NOT  encoder  


Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  

hLp://SecurityTube-­‐Training.com    

©SecurityTube.net  
NOT  Encoder  

•  Transform  every  byte  in  your  shellcode  using  


NOT  

•  Decoder  will  NOT  the  encoded  byte  to  get  the  


original  shellcode  byte  

•  Pass  control  to  shellcode  ayer  all  bytes  


decoded  

©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Module  2:  IntroducSon  to  Shellcoding  

10.  Inser4on  Encoder  


Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  

hLp://SecurityTube-­‐Training.com    

©SecurityTube.net  
InserSon  Encoder?  

Original  Shellcode   0x12   0xab   0xac   0x01   ………  

Ayer  InserSon   0x12     0xaa   0xab   0xaa   0xac   0xaa   0x01   0xaa   ………  

Inser4on  Decoder  Stub   0x12     0xaa   0xab   0xaa   0xac   0xaa   0x01   0xaa   ………  

Original  Shellcode  
Inser4on  Decoder  Stub   0x12   0xab   0xac   0x01   ………  

©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Module  2:  IntroducSon  to  Shellcoding  

11.  XOR  Decoder  using  MMX  


Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  

hLp://SecurityTube-­‐Training.com    

©SecurityTube.net  
Ton  of  instrucSons!    

•  FPU  

•  MMX  

•  SSE  

•  SSE2  

©SecurityTube.net  
Advantages  

•  ExisSng  “popular”  shellcodes  hardly  use  them  

•  Probably  detecSon  rates  lesser  by  AV  and  


other  analysis  tools  

•  Easy  to  replicate  exisSng  funcSonality  using  


these  extensions  

©SecurityTube.net  
MMX    based  XOR  Decoder  
•  SIMD  –  Single  instrucSon  mulSple  data    

•  Registers  MM0  to  MM7  

•  Can  load  8  bytes  qword    

•  Moving  Data  –  movq  

•  XOR’ing  Data  –  pxor  

•  Key  Difference  from  the  previous  XOR  decoder  


–  Operates  over  8  bytes  at  the  same  Sme  

©SecurityTube.net  
Using  the  FPU  for  GetPC  

Source:  hLp://skypher.com/wiki/index.php/Hacking/Shellcode/GetPC    

FSTENV  stores  control,  status  and  tag  word,  instruc4on  pointer,  data  pointer  and  last  opcode  

©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Module  2:  IntroducSon  to  Shellcoding  

12.  Polymorphism  
Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  

hLp://SecurityTube-­‐Training.com    

©SecurityTube.net  
Easy  FingerprinSng  of  Basic  Shellcode  

•  AV  and  IDS  can  use  the  shellcode  as  a  paLern  


to  search  

•  Easy  to  fingerprint    

•  DetecSon  simple  

©SecurityTube.net  
Encoding  and  EncrypSon  

•  Original  shellcode  protected  


 
•  Decoder  /  Decryptor  Stub  however  small,  is  
prone  to  fingerprinSng  

•  Back  to  square  1  J  

©SecurityTube.net  
Imagine  IF  

•  We  could  make  our  shellcode  look  different  


everySme  we  create  it  

•  FuncSonality  remains  the  same  

•  SemanScally  equivalent  instrucSons  

DetecSon  is  now  MUCH,  MUCH  Difficult  


 
Enter  Polymorphism  

©SecurityTube.net  
Origins  in  the  Virus  World  

Source:  hLp://www.phrack.org/issues.html?issue=61&id=9#arScle      

©SecurityTube.net  
Basic  Principle  of  Create  Polymorphic  
Shellcode  
•  Replace  instrucSons  with  equivalent  
funcSonality  ones  

•  Add  garbage  instrucSons  which  don’t  change  


funcSonality  in  any  way  “NOP  Equivalents”  

©SecurityTube.net  
Polymorphic  Engines  

•  ADMutate:  
–  hLp://www.ktwo.ca/readme.html    
–  hLp://www.youtube.com/watch?v=XMt9ExL9I00    

•  CLET  
–  hLp://www.phrack.org/issues.html?
issue=61&id=9#arScle    

•  VX  Heavens  Mirror  
–  hLp://download.adamas.ai/dlbase/Stuff/VX
%20Heavens%20Library/staSc/vdat/mainmenu.htm    

©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Module  2:  IntroducSon  to  Shellcoding  

13.  Analyzing  3rd  Party  Shellcode  


Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  

hLp://SecurityTube-­‐Training.com    

©SecurityTube.net  
Should  I  run  this?  

©SecurityTube.net  
Analyzing  Shellcode  

•  Use  GDB    

•  Use  Ndisasm  

•  Libemu  –  Shellcode  emulaSon  


 hLp://libemu.carnivore.it/    

©SecurityTube.net  
Staged  Shellcode  

•  Divided  into  2  stages:  

–  First  stage  is  small  and  loads  the  second  stage  


•  from  input    
•  from  a  file  /  over  a  network  

–  First  stage  passes  control  to  the  second  stage  

•  Useful  when  very  less  space  to  run  shellcode  in  


an  exploit  

©SecurityTube.net  
Case  Study:  Analyzing  Staged  Shellcode  

Source:  hLp://www.shell-­‐storm.org/shellcode/files/shellcode-­‐824.php    

©SecurityTube.net  
Network  based  second  stage  loading  

•  Bind  TCP  (staged)    

•  Reverse  TCP  (staged)  

•  Meterpreter  is  staged  J    

©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Module  2:  IntroducSon  to  Shellcoding  

14.  Analyzing  Shell_Bind_TCP    


and  Shell_Reverse_TCP  with  Libemu  
Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  

hLp://SecurityTube-­‐Training.com    

©SecurityTube.net  
Shell_XXX_TCP  

•  Binding  a  Shell  is  the  most  common  way  to  get  


command  line  access  to  a  compromised  
system  

•  Bind  Shell  (Listening  on  vicSm’s  port)  

•  Reverse  Shell  (Connects  back  to  ALacker’s  


port)  

©SecurityTube.net  
Libemu  

hLp://libemu.carnivore.it/    

©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Module  2:  IntroducSon  to  Shellcoding  

14.  Crypters  
Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  

hLp://SecurityTube-­‐Training.com    

©SecurityTube.net  
Crypters  

•  Encrypt  Executable  /  Shellcode  

•  Decrypt  at  runSme  and  run  

•  For  powerful  crypto  techniques  like  RC4,  AES  


etc.  a  lot  of  assembly  code  

•  Shellcode  size  too  large  to  be  useful  

©SecurityTube.net  
RC4  

•  Symmetric  Stream  Cipher    

•  2  Step  process:  
–  Key  Scheduling  Algorithm  

–  Pseudo  Random  Number  GeneraSon    

•  Full  Details:  hLp://en.wikipedia.org/wiki/RC4    

©SecurityTube.net  
WriSng  an  RC4  Shellcode  Crypter  in  C  

•  EncrypSon  Phase:    
–  For  a  given  key,  encrypts  shellcode  

•  DecrypSon  Phase:  
–  For  the  same  key,  decrypts  shellcode  
–  Executes  it  

©SecurityTube.net  
Chaining  Methods  

•  Create  Shellcode    

•  Encode  with  XOR  

•  Encrypt  with  Crypter  (needs  to  be  the  last)  

©SecurityTube.net  
RC4  in  Assembly  

•  hLps://thunked.org/programming/rc4-­‐in-­‐
assembly-­‐t23.html  

•  hLp://youritguy.wordpress.com/2010/06/13/
adler-­‐32-­‐and-­‐rc4-­‐in-­‐inline-­‐assembly/    

•  hLp://nayuki.eigenstate.org/page/rc4-­‐cipher-­‐
in-­‐x86-­‐assembly    

©SecurityTube.net  
Hyperion  

•  PE  Cryptor  

•  hLp://www.exploit-­‐db.com/wp-­‐content/
themes/exploit/docs/18849.pdf    

•  Encrypted  (AES)  with  weak  key  

•  Key  bruteforced  at  runSme    

©SecurityTube.net  
SecurityTube  Linux  Assembly  Expert  
(SLAE32)  

Training:      hLp://www.SecurityTube-­‐Training.com    
 
Community:  hLp://www.SecurityTube.net    

Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  
©SecurityTube.net  
NoSce  

This  video  is  part  of  the  SecurityTube  Linux  


Assembly  Expert  course.  A  limited  number  of  
videos  in  this  course  will  be  released  on  
SecurityTube.net    
 
For  full  access  to  all  theory  and  exercise  videos,  
PDF  slides,  Code  snippets  etc.  Please  register  as  a  
student  by  visi4ng:  
 
hLp://securitytube-­‐training.com    

©SecurityTube.net  
Module  3:  CerSficaSon  Exam  

The  Grand  Finale  


Vivek  Ramachandran  
SWSE,  SMFE,  SPSE,  SGDE,  SISE,  SLAE32  Course  Instructor  

hLp://SecurityTube-­‐Training.com    

©SecurityTube.net  
Exam  Format  

•  7  Assignments  of  varying  difficulty  

•  Post  soluSons  to  your  personal  blog  


–  wordpress.com,  Blogger  or  your  own  domain  

•  Store  code  in  a  Github  account  

©SecurityTube.net  
Assignment  #1  

•  Create  a  Shell_Bind_TCP  shellcode  


–  Binds  to  a  port    
–  Execs  Shell  on  incoming  connecSon  

•  Port  number  should  be  easily  configurable  

©SecurityTube.net  
Assignment  #2  

•  Create  a  Shell_Reverse_TCP  shellcode  


–  Reverse  connects  to  configured  IP  and  Port  
–  Execs  shell  on  successful  connecSon  

•  IP  and  Port  should  be  easily  configurable  

©SecurityTube.net  
Assignment  #3  

•  Study  about  the  Egg  Hunter  shellcode  

•  Create  a  working  demo  of  the  Egghunter  

•  Should  be  configurable  for  different  payloads  

©SecurityTube.net  
Assignment  #4  

•  Create  a  custom  encoding  scheme  like  the  


“InserSon  Encoder”  we  showed  you  

•  PoC  with  using  execve-­‐stack  as  the  shellcode  


to  encode  with  your  schema  and  execute  

©SecurityTube.net  
Assignment  #5  

•  Take  up  at  least  3  shellcode  samples  created  


using  Msfpayload  for  linux/x86    

•  Use  GDB/Ndisasm/Libemu  to  dissect  the  


funcSonality  of  the  shellcode  

•  Present  your  analysis  

©SecurityTube.net  
Assignment  #6  

•  Take  up  3  shellcodes  from  Shell-­‐Storm  and  


create  polymorphic  versions  of  them  to  beat  
paLern  matching  

•  The  polymorphic  versions  cannot  be  larger  


150%  of  the  exisSng  shellcode  

•  Bonus  points  for  making  it  shorter  in  length  


than  original  

©SecurityTube.net  
Assignment  #7  

•  Create  a  custom  crypter  like  the  one  shown  in  


the  “crypters”  video  

•  Free  to  use  any  exisSng  encrypSon  schema  

•  Can  use  any  programming  language  

©SecurityTube.net  
Blog  post  must  menSon  

This  blog  post  has  been  created  for  compleSng  


the  requirements  of  the  SecurityTube  Linux  
Assembly  Expert  cerSficaSon:  
 
hLp://securitytube-­‐training.com/online-­‐
courses/securitytube-­‐linux-­‐assembly-­‐expert/    
 
Student  ID:    SLAE-­‐XXXXX  

©SecurityTube.net  
EvaluaSon  Criteria  

•  Originality  of  Shellcode  

•  Quality  of  ExplanaSon  –  detailed  and  insighƒul    

•  Each  Assignment  carries  10  marks  

•  CerSficaSon  Criteria:    >  50  out  of  70  marks  

©SecurityTube.net  
Extra  Points  J  
•  PosSng  addiSonal  new  shellcodes  beyond  the  
assignments  (10  points)  

•  Shellcode  submiLed  to  and  accepted  by:  

–  Shell-­‐Storm.org  
–  Exploit-­‐db.com    
 
(10  points)  
 
•  Community  InteracSon    (5  points)  
–  ChaLer  on  TwiLer,  Facebook  
–  Comments  on  Blog  posts  
©SecurityTube.net  
Submission  Format  

•  Email  to  [email protected]    

•  Subject:    SLAE  Exam  Blog  Posts  

•  Email  contains:  
–  Links  to  all  7  blog  posts  
–  Link  to  Gitgub  account  where  code  is  stored  
–  Link  to  Shell-­‐Storm  /  Exploit-­‐db  submissions  
–  Link  to  TwiLer  /  Facebook  if  posted  there  

•  Around  5  working  days  for  result  

©SecurityTube.net  

You might also like