How to enable Python to craft packets and listen to ports less than 1024 without sudo

To be able to craft packets with Scapy, you have to either use sudo or allow setcap for your python environment. I don’t prefer to use sudo when working with my Anaconda environments, so I did the following:

sudo setcap 'cap_net_raw,cap_net_admin,cap_net_bind_service=eip' /home/ubuntu/anaconda3/envs/py311/bin/python3.11

Note: Using in the above example python instead of python3.11 won’t work, since python in that location is just a symbolic link, you have to specify the executable itself directly.

That’s it, now you can run your program without sudo!

Enjoy!

Posted in Linux | Tagged , , | Leave a comment

How to run wireshark/tshark or tcpdump to capture packets inside IPMininet using screen

This has been a bit confusing for some time, but after you run your ipmininet network with Python, you want to capture some packets with wireshark/tshark or tcpdump, here is the way you can do it:

Let’s assume we have a host named h1, now at the prompt of mininet:

mininet> h1 screen -S tcpdump

This will take you to a screen terminal where you can run tshark or tcpdump inside it, then Press Ctrl+A then D to detach from out.

After that do whatever command you want, e.g. h1 wants to ping h2

mininet> h1 ping h2

After you are done and you want to collect the results, just run:

mininet> h1 screen -r

you will find the results captured by tcpdump there, which you can copy or screenshot or whatever you want. Finally type exit to destroy the screen session.

Enjoy!

Note: I was using the vagrant installation method of ipmininet.

Thanks Jeril for the tip 😉

Posted in Linux | Tagged , , , , , | Leave a comment

Restart Ethernet Adapter using PowerShell on Windows

In case you are having a problem with your Ethernet adapter, such as not connecting properly or obtaining an IP address when you insert the cable (happens with me sometimes in one of the networks I connect to), you can do the following:

Create a file named “restart_ethernet.ps1”, add the following content to it and save:

# Disable the network adapter
Disable-NetAdapter -Name "Ethernet" -Confirm:$false

# Wait for 5 seconds
Start-Sleep -Seconds 5

# Enable the network adapter
Enable-NetAdapter -Name "Ethernet"

Now, on your Desktop, right click, create a Shortcut and add the following content to the location section:

powershell.exe -ExecutionPolicy Bypass -File "C:\restart_ethernet.ps1"

Save it with a meaningful name such as Restart Ethernet or something. After you are done, just right click on it and choose “Run As Administrator”, and it’s done:

Enjoy!

Note: In case “Ethernet” doesn’t work with you, run Get-NetAdapter and it should list all the network adapters in your network and choose the correct one.

Posted in Windows | Tagged , , | Leave a comment

Fix Clipboard Copy/Paste Functionality with Windows 11 Pro Host, VMWare Workstation 16 Pro and Ubuntu 16.04 32-bit Guest

#!/bin/bash
processString=$(ps -ef | grep '[0-9][0-9]:[0-9][0-9]:[0-9][0-9] /usr/bin/vmtoolsd -n vmusr') # get process info for vmtoolsd
tokens=( $processString ) # tokenize
kill "${tokens[1]}" # grab pid and kill it
/usr/bin/vmtoolsd -n vmusr & > /dev/null 2>&1 # restart vmtoolsd

That’s it, Enjoy!

Source: https://superuser.com/questions/587767/clipboard-operations-copy-paste-often-stop-working-on-vmware-workstation/1323289#1323289?newreg=6f4bb599af1c44edb3f818c50d344fea

Posted in Linux | Tagged , , | Leave a comment

Installing latest version of gef on Ubuntu 16.04 32-bit

If you are having trouble installing gef on Ubuntu 16.04 32-bit, you may follow these steps:

Install python3.6 and python3.6-dev:

sudo add-apt-repository -y ppa:jblgf0/python
sudo apt-get update
sudo apt-get install python3.6 python3.6-dev

Install texinfo package (since you would the makeinfo command to be available for successful installation of gdb):

sudo apt install texinfo

Download gdb 8.2 from https://ftp.gnu.org/gnu/gdb/gdb-8.2.tar.gz, then unpack and cd to the folder.

To start compilation, you have to explicitly instruct the compiler to use python3.6 through the configuration script:

./configure --with-python=/usr/bin/python3.6
make
sudo make install

After that, just install gef normally per the instructions on the website:

bash -c "$(curl -fsSL https://gef.blah.cat/sh)"

That’s it, Enjoy!

Posted in Linux | Leave a comment