On the first lab we wil cover introduction to the labs, setup, and sniffing/spoofing (topics are listed below with more detail). We may use computers which are available in the lab, but bring your own laptop too, so you can setup it properly for the remote labs that will follow.
If you use the computers in the lab, the native Linux installed there may default to the Polish language. In order to change it to English (in a terminal window), type the following:
export LANG=en_US.UTF-8 export LANGUAGE=en_US.UTF-8This way you will have the system responses, errors, dates, etc. in English locale.
Introduction to lab environment, accounts setup, working with virtual systems in the lab, review of the Linux system basics
Setup of the virtual system:
Group 2 (B): Thursday 14.11.2024,
Group 1 (A): Monday 18.11.2024,
Group 3 (C): Monday 25.11.2024
Detailed tasks:
Use some filters in wireshark to limit the number of packets you see and focus on the important stuff. For FTP with ftp.icm.edu.pl you may use something like:
Make sure that you are using the right network interface for sniffing. Make screenshots of interesting screens where you have required information. Also -- at the end of wireshark session save data to a pcap file, so if you miss something for the final report, you will be able to read the captured data again and find information that you missed.
If you are using SEED Labs virtual system, Scapy should be already installed there. Also -- to construct your own ICMP packets or do network sniffing you need root access, so make sure you run the programs with appropriate privileges. Install Scapy for Python: https://scapy.readthedocs.io/en/latest/installation.html, (The "pip install" method should work without any problems). Do also a "pip install ipython" to have a better interactive python interface for running scapy. Create a script for capturing packets. Customize this script to show only selected packets. Make sure that you run this script with root privilleges (e.g. after "sudo bash"). Choose packets based on:
Modify the display filter to show the interesting information, -- e.g. the contents of FTP control channel where passwords can be seen.
Construct an ICMP PING packet (icmp type 8) with spoofed source address and send it (you should be able to see the sent packet and the response in wireshark). Start with doing this in interactive scapy/ipython, then write it also as the python script that can be run from thw shell. Observe the packet in wireshark (and make a screenshot of it) and in scapy sniffing program.
In interactive scapy:
conf.color_theme=BrightTheme() explore() # use IPv4 layers pkt=IP(proto="udp") pkt.show() u=UDP() pkt2=pkt/u pkt2.show() pkt2.dport=53 pkt2.dst="156.17.1.1" ... send(pkt2)Scapy basic program for packet sniffing:
#!/usr/bin/python from scapy.all import * print("SNIFFING PACKETS.........") def print_pkt(pkt): print("Source IP:", pkt[IP].src) print("Destination IP:", pkt[IP].dst) print("Protocol:", pkt[IP].proto) print("\n") pkt = sniff(iface=["enp0s3","enp0s8"],filter='ip',prn=print_pkt)Some links to see: https://gaia.cs.umass.edu/kurose_ross/wireshark.php
https://scapy.readthedocs.io/en/latest/usage.html
Group 1 (A): Monday 2.12.2024
Group 2 (B): Thursday 23.11.2024
Group 3 (C): Monday 9.12.2024
After the lab, write a report showing the tasks you have performed (and put it in the ePortal task). Include as separate files:
Upload these files just after or during the lab (remember NOT TO click on the "final" version). Then write the report after the lab in the PDF format. You have one week after the lab to do so. Tick the "final" version when you upload the report (you may still update the already sent files until this final tick).
Public key of the teacher can be downloaded from here.
If you want to properly test if this is the correct key, check it's fingerprint. It should be this:
Key fingerprint = 63FC 8412 8830 28C8 3C47 0F7D AE49 6244 4239 1952You may also test if the key has been imported correctly by verifying a signature of this message or this.
Group 1 (A): Monday 16.12.2024
Group 2 (B): Thursday 12.12.2024
Group 3 (C): Monday 20.01.2025
Create CA, create server certificate, sign it with CA,install apache to use this certificate
Create user certificates, configure server to use them to allow access to some directories based on identity of a client, checked by the client certificate. Provide also some common directory for all clients signing with certificates issued by your CA.
Group 1 (A): Monday 13.01.2025
Group 2 (B): Thursday 23.01.2025
Group 3 (C): Monday 31.01.2025
Download a zip file from this directory and unpack it inside a virtual system. If necessary, you may need to add execution bit (chmod a+x keygen-en) for binary programs that have been unpacked in order to run them.
There are two subdirectories there, and two tasks to do
This one is just for a warm-up and should be quite easy (no more than 30 minutes).
There are three programs: buffer1, buffer2 and buffer3 - all very similar, but for the first one you have also the source code in C and assembly-level source in buffer1.s (generated automatically through gcc -- see Makefile how to do it), fot buffer2 you have only .s file, the third one is just binary
Your task is to find and report two numbers for programs 2 and 3:
These 2 values are not equal for programs 2 and 3. For program 1 the buffer size is 80 characters (you can see it clearly in the source code) and if you run the program with an argument which is exactly 80 characters long, the null-terminating '\0' character at the end of string (at position 81) will not fit into the buffer and overwrite the next variable. Add 5 more characters and you will get Segmentation Violation as you overwrite stored EBP value that messes up the main() function after return.
Run program keygen-eng-1. It asks for a user number and a password. If you give user number "0" and password "12345678" it will say that "you passed". If user number is other than zero, the password is not so simple :-)
Your task is to find out what password should be entered if you give your student ID number as user ID.
Use the gnu debugger (gdb) or other tools (maybe some code de-compilers?) to find out what this program does, how the password is generated. The program does not have a symbol table, so in order to start it under the debugger, set breakpoint to:
break __libc_start_mainthen
runto start the program and catch it when it enters the
main
function. Another useful gdb command to use:
set disassemble-next-line onThis will automatically disassemble few next lines every time the gdb stops program. At any time you may also issue
disassemble
command to see disassembled code of the sorrounding area, and use commands such as
si
(step instruction)
or
ni
(next instruction)
to do step-by-step program execution to find how it works.
Also, remember about the
p
or
print
commands to inspect variables and registers, and
x
command to inspect the memory at a given address.
Some basic gdb
commands that may be useful:
command | shortcut | description |
nexti | ni | execute one assembly-level instruction, going over function calls |
stepi | si | execute one assembly-level instruction, step into functions |
run | run the program from the beginning. If you need to pass parameters to the program, do it here, i.e. "run abcdef" will pass "abcdef" as argv[1] to the started process | |
break | br | set breakpoint at some location (function name or *0x0000abcd for a memory address -- note the star sign at the beginning of the address) |
continue | c | continue execution until next breakpoint |
p | print some value. Examples: $register_name, *$esi, *(int*) $esi; *(char*) $esi, print/x for hex value |
|
info | info registers (all CPU registers); info breakpoints (all breakpoints) |
|
backtrace | bt | show current function frame - and stack contents |
disassemble | disas | disassemble current function, or another function: disassemble main or a range of memory addresses: disassemble 0xadd0,0xadd1
|
x | dump memory. Examples: x $esi, x/32 $esi, x/16c 0x123456, x/s 0x456789 (/s - treat it as STRING, /c - as char*, /32 - dump 32 values, etc.) |
|
ENTER | pressing ENTER key repeats the last command, e.g. if you type ni first, then pressing ENTER several times repeats ni commands |
The gdb which is installed in the SEED virtual system comes with ~/.gdbinit file, which contains the following line:
source /home/seed/source/gsbpeda/peda.pyThis loads an overlay to GDB which is much nicer to work with, as it gives you persistent display of current code, memory and registers. However - if the debugged program prints something on the screen, it may get messy, as PEDA redraws the whole screen with its output. So it may be actually desirable to run GDB sometimes without PEDA extensions - you can do it by commenting out this "source" line with the hash sign (#). And if you start gdb without PEDA, you can always switch it on at any moment, by just executing this source command (just paste it in the GDB input).
Also, you may run the program by itself (without gdb) in one window, then in another window - type "gdb keygen-eng-1", but instead of starting the program with the "run" command - attach to an already running process - type "attach PID", where PID is the process ID of the running program (find it with the ps command), so, for example: