Skip to content

Instantly share code, notes, and snippets.

@PSJoshi
PSJoshi / networking_datasets.md
Created August 30, 2023 05:21 — forked from stefanbschneider/networking_datasets.md
List of datasets related to networking. Useful for data-driven evaluation or machine learning approaches. Feel free to comment with updates.
@PSJoshi
PSJoshi / nmap-scans.md
Created November 1, 2022 12:16
Using Nmap to detect vulnerabilities

Converting Nmap xml reports to html

Nmap is popular network scanner for scanning of ports and vulnerabilities and supports various output formats like XML. As a result, scan data can be parsed by other tools such as Metasploit or ZenMap GUI. For human readability, nmap scan output can be formatted to a nice HTML report using tool like xsltproc.

Typical Nmap scan command looks like

# nmap -sTV -p- -A -T4 -vvvv -oA  
@PSJoshi
PSJoshi / systemctl-commands.md
Created October 18, 2022 12:55
Common systemctl commands

Systemctl commands

  • List services
# systemctl list-units --type=service
  • Show running services
# systemctl list-units --type=service --state=running 
  • List all services
@PSJoshi
PSJoshi / raspberry-pi-repos.md
Created October 17, 2022 11:48
Why different repositories for Raspberry Pi

Explanation for different repositories for Raspberry Pi

File:/etc/apt/sources.list
deb http://raspbian.raspberrypi.org/raspbian/ bullseye main contrib non-free rpi
deb http://archive.raspberrypi.org/debian/ bullseye main

deb http://deb.debian.org/debian bullseye main contrib non-free
deb http://security.debian.org/debian-security bullseye-security main contrib non-free
deb http://deb.debian.org/debian bullseye-updates main contrib non-free
@PSJoshi
PSJoshi / watchdog-setup.md
Created October 12, 2022 10:06
Setting watchdog on Raspberry Pi

Setting watchdog timer in Raspberry Pi

  • Check WDT module is enabled in kernel In recent raspberry pi boards, the module for watchdog is bcm2835_wdt and it comes precompiled into kernel directly. So it doesn’t have to be enabled manually anymore and also it will not show when running lsmod.

To check if you have this module precompiled in kernel, you can run:

pi@raspberrypi:~ $ sudo cat /lib/modules/$(uname -r)/modules.builtin | grep wdt
kernel/drivers/watchdog/bcm2835_wdt.ko
pi@raspberrypi:~ $ sudo cat /var/log/kern.log* | grep watchdog
Oct 31 12:17:02 raspberrypi kernel: bcm2835-wdt bcm2835-wdt: Broadcom BCM2835 watchdog timer
@PSJoshi
PSJoshi / smart-card.md
Created October 12, 2022 06:38
Access smart card details using python
  • Install smart card driver - PC/SC (Windows/Linux smart card base components)
# apt-get update
# apt-get install pcscd

# check if smart card is detected
# lsusb

# apt install pcsc-tools
# pcsc_scan
@PSJoshi
PSJoshi / SD-card-information.md
Last active September 23, 2022 07:55
Read SD memory card information

Read SD memory card information

$ sudo udevadm info -a -n /dev/sdb

SD card vendors should be in /sys/class/mmc_host within /sys/class

Try searching /sys for some MMC (SD) specific keywords for ARM-based embedded system

$ find /sys -name "oemid"
@PSJoshi
PSJoshi / ssl-certificate-generation.md
Created September 13, 2022 12:25
Generate self signed certificate

Generate self signed certificate

Self-signed certificates are convenient when developing locally. Of course, these are not be used in production environments. If you are running a public site, it's recommended to use any commercial certificate recognized by Browser. "Let's Encrypt" has revolutionalized the certificate eco-system and you can easily use/deploy them on public facing websites.

For experimentation and testing, self-signed certificates is the easiest approach. Steps to get self-signed certificate are given below:

  • Install openssl
# apt-get install openssl
@PSJoshi
PSJoshi / clear-ram-swap.md
Created August 23, 2022 09:58
Clear RAM cache and Swap space

Clear RAM-cache and Swap in Linux

It is possible to clear cache without interrupting any process or service. sync will flush the file system buffer and drop_cache will clean cache without killing any application/service.

Clear PageCache only

# sync; echo 1 > /proc/sys/vm/drop_caches

Clear inodes

@PSJoshi
PSJoshi / cron-job.sh
Created August 17, 2022 12:33
Cron job using bash script
### Cron job using bash script
```
#!/bin/sh
crontab -l > cron_backup
echo "0 10 * * * sudo /home/<user>/job.sh >/dev/null 2>&1" >> cron_backup
crontab cron_backup
rm cron_backup
```
Another version
```