Skip to content

Instantly share code, notes, and snippets.

@joshschmelzle
Last active December 15, 2021 16:06
Show Gist options
  • Save joshschmelzle/fde30a904c9c8b4ee92ac270ccfdfb15 to your computer and use it in GitHub Desktop.
Save joshschmelzle/fde30a904c9c8b4ee92ac270ccfdfb15 to your computer and use it in GitHub Desktop.
WLAN Pi Tricks

Remote PCAP

Requirements:

  • Windows 10, or newer
  • Wireshark 3.0, or newer (installed with Sshdump component)
  • WLAN Pi or SBC (assumption is rpcapd is setup and running)
  • SSH Client

Can leverage rpcap (remote packet capture) protocol supported by Wireshark to capture raw wireless frames from the WLAN NIC used by the WLAN Pi. This can be leveraged to do a packet capture from a WLAN Pi in a remote location.

  1. Establish SSH session to your WLAN Pi.
  2. Run this command sudo /usr/local/sbin/rpcapd -dn. The rpcap daemon should be running.

Control the Capture Channel

  • sudo iw wlan0 set channel <channel> [NOHT|HT20|HT40+|HT40-|5Mhz|10MHz|80MHz]
  • sudo iw wlan0 set channel 36 HT40+
  • sudo iw wlan0 set channel 6

Prep Interface and Setup Remote PCAP Daemon Example

sudo airmon-ng check kill
sudo ip link set wlan0 down
sudo iw dev wlan0 set type monitor
sudo ip link set wlan0 up
sudo iw wlan0 set channel 36 
sudo /usr/local/sbin/rpcapd -dn

If RPCAPD is not installed...

libpcap depends

Example problem during configure:

checking for flex... no
checking for lex... no
configure: error: Neither flex nor lex was found.

Required:

sudo apt install flex bison

libpcap install

Clone via SSH:

git clone [email protected]:the-tcpdump-group/libpcap.git

If you don't have SSH keys setup, clone via HTTPS:

git clone https://github.com/the-tcpdump-group/libpcap.git

Ok, let's configure, make, and install!

cd libpcap
./configure --enable-remote
make
sudo make install

Verify rpcapd is installed and on your $PATH:

$ which rpcapd
/usr/local/sbin/rpcapd
" global yanking with the OS clipboard
set clipboard=unnamed
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'scrooloose/nerdtree'
Plugin 'tpope/vim-surround'
Plugin 'scrooloose/syntastic'
Plugin 'airblade/vim-gitgutter'
Plugin 'scrooloose/nerdcommenter'
Plugin 'bling/vim-airline'
Plugin 'romainl/vim-cool'
call vundle#end() " required
filetype plugin indent on " required
" make the arrow keys do something useful, resize the viewports accordingly.
nnoremap <Left> :vertical resize +2<CR>
nnoremap <Right> :vertical resize -2<CR>
nnoremap <Up> :resize -2<CR>
nnoremap <Down> :resize +2<CR>
syntax on " enable syntax highlighting
set encoding=utf-8 " the encoding displayed
set fileencoding=utf-8 " encoding written to file
" Change color when entering insert mode
autocmd InsertEnter * highlight CursorLine ctermbg=lightblue ctermfg=Black
" Revert color to default when leaving insert mode
autocmd InsertLeave * highlight CursorLine ctermbg=None ctermfg=None
" make wildmenu behave like bash completion. finding commands are so easy now.
set wildmode=list:longest
set wildmenu " display all matching files
set path+=** " provides tab-completion for all file-related
set showcmd " show partial commands in the last line of the screen
set number " numbering
set confirm " raise dialogue asking if you wish to save file
set history=500 " set how many lines of history VIM has to remember
set autoread " set to auto read when a file is changed from the outside
set autoindent
" 4 spaces instead of tabs
set shiftwidth=4
set tabstop=4
set expandtab
colorscheme industry
syntax on
set ruler
set visualbell
set encoding=utf-8
set wrap
set lazyredraw
set ruler
set backspace=indent,eol,start
set laststatus=2
set showmode
set hlsearch
set incsearch
set ignorecase
set smartcase
set showmatch
set t_Co=256
set background=dark

On Ubuntu 18.04, launch nm-connection-editor from the terminal.

When it opens, select the wired connection item, clicking the edit button (the cog). In that menu, switch to the IPv4 tab, and select the method: ‘shared to other computers’.

After that, save everything and connect your cable if you haven’t already, and DHCP should kick-in and set everything up for you!

You could even connect a switch or hub and share the connection further, if you wanted.

Note that if you need to get the IP address of the connection, you can use ifconfig. You’ll only need this if DHCP doesn’t automatically configure everything.

Source: https://crookm.com/journal/2018/sharing-wifi-connection-over-ethernet/

Uncomment the last two lines in /etc/network/interfaces

sudo vim /etc/network/interfaces:

# USB Ethernet (DHCP)
auto usb0:0
iface usb0:0 inet dhcp

This should create a 2nd virtual USB interface that requests DHCP

That IP won’t show up on the front display, but mdns should work / you’ll have to use an IP scanner.

Additionally, that IP will change on reboot, as the MAC address gets randomly created on each reboot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment