CSE 545 Essentials for Software Security Tiffany Bao tbao@asu

13 Slides562.03 KB

CSE 545 Essentials for Software Security Tiffany Bao [email protected]

Contents C 101 Python 101 Bash 101 2

C 101

#include stdio.h #include string.h #include stdlib.h typedef struct s book{ int id; char name[50]; char author[50]; int nPages; } Book; Output: Book I's name: Harry Potter and the Philosopher's Stone void initI(Book *book){ book - id 1; strcpy(book - name, "Philosopher's Stone"); strcpy(book - author, "J.K. Rowling"); book - nPages 223; } int main(){ Book harryPotterI; initI(&harryPotterI); printf("Book I's name: Harry Potter and the %s\n", harryPotterI.name); return 0; }

#include stdio.h #include string.h #include stdlib.h typedef struct s book{ int id; char name[50]; char author[50]; int nPages; } Book; Output: Book II's name: Harry Potter and the void initII(Book book){ book.id 2; strcpy(book.name, "Chamber of Secrets"); strcpy(book.author, "J.K. Rowling"); book.nPages 251; } int main(){ Book harryPotterII {0}; initII(harryPotterII); printf("Book II's name: Harry Potter and the %s\n", harryPotterII.name); return 0; }

#include stdio.h #include string.h #include stdlib.h typedef struct s book{ int id; char name[50]; char author[50]; int nPages; } Book; void initIII( ){ book - id 3; strcpy(book - name, "Prisoner of Azkaban"); strcpy(book - author, "J.K. Rowling"); book - nPages 317; } Initialization int main(){ Book *harryPotterIII; harryPotterIII (Book*) malloc(sizeof(Book)); initIII( ); printf("Book III's name: Harry Potter and the %s\n", harryPotterIII - name); free(harryPotterIII); return 0; }

Python 101

We are going to Write an interactive server Interact with the server

Bash 101

1. Run the service we wrote in Python 101 xinetd tcpserver 2. Connect and interact with the service nc 3. Use the client script to interact

In-class Lab

Goal: Log in your part icipation Service IP: 107.21.135.41 Port: 2222 Connect to the server: nc 107.21.135.41 2222 Service file: https://cse545.tiffanybao.com/labs/week2/service vuln.c https://cse545.tiffanybao.com/labs/week2/service

What we learn Run service locally Debug your script in python Use pwntools

Back to top button