Skip to content

Commit

Permalink
added more utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiocicerchia committed Jun 8, 2020
1 parent 54414a6 commit c00e40b
Show file tree
Hide file tree
Showing 15 changed files with 189 additions and 3 deletions.
115 changes: 112 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,42 @@
# Utils

## Requirements

- Python3
- Ghostscript

## Install

One liner:

```shell
wget -O- https://raw.githubusercontent.com/fabiocicerchia/utils/master/installer | sudo sh
```

## Tools

### Benchmark
### `benchmark` - Benchmark URL

```shell
$ benchmark URL
0.12345 sec
```

### Check Accessibility
### `blink_port` - Blink NIC led

```shell
$ blink_port [NIC=eth0] [TIME=5]
```

### `cert_expire` - SSL/TLS Certificate Expiration

```shell
$ cert_expire DOMAIN
notBefore=May 20 11:55:41 2020 GMT
notAfter=Aug 12 11:55:41 2020 GMT
```

### `check_accessibility` - Check Accessibility

```shell
$ check_accessibility URL
Expand All @@ -26,7 +53,7 @@ Validate Accessibility (WCAG 2.0 - Level AAA):
OK|FAIL
```

### Check Validation
### `check_validation` - Check Validation

```shell
$ check_validation URL
Expand All @@ -51,6 +78,88 @@ Validate Links:
OK|FAIL
```

### `expose` - Expose Folder to HTTP port

```shell
$ expose [PORT=8080]
Serving HTTP on 0.0.0.0 port 8080 (http://0.0.0.0:8080/) ...
```

### `gen_passwd` - Generate Password

```shell
$ gen_passwd [LEN=16]
*******
```

### `git_change_date` - Git Change Date

```shell
$ git_change_date "Mon 08 Jun 2020 20:19:19 CET"
```

### `git_commit` - Git Commit Random Message

```shell
$ git_commit
```

### `ip_location` - IP Location

```shell
$ ip_location 123.123.123.123
Italy
IT
Rome
```

### `ip_public` - Public IP Address

```shell
$ ip_public
123.123.123.123
```

### `mac_random` - Random MAC Address

```shell
$ mac_random
86:ed:59:63:20:58
```

### `pdf_compress` - Compress PDF's size

```shell
$ pdf_compress FILE.PDF
```

### `server_specs` - Server Specs

```shell
$ server_specs
CPU: 4
RAM: 16384 MB
Swap: 2048 MB
Disk: 10Gi
Avg load: 1.53 1.87 1.91
IP Private: 192.168.0.2
IP Public: 123.123.123.123
Location: Italy
```

### `stealth` - Disable Command History

```shell
$ stealth
```

### `timestamp` - Convert Timestamp

```shell
$ timestamp 1234567890
Fri Feb 13 15:26:30 EST 2009
```

## Notes

- Freeze the requirements: `pip3 freeze > requirements.txt`
Expand Down
10 changes: 10 additions & 0 deletions blink_port
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh
NIC=eth0
if [ "$1" != "" ]; then
NIC=$1
fi
TIME=5
if [ "$2" != "" ]; then
TIME=$2
fi
ethtool -p $NIC $TIME
3 changes: 3 additions & 0 deletions cert_expire
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
DOMAIN=$1
echo | openssl s_client -connect $DOMAIN:443 2>/dev/null | openssl x509 -dates -noout
6 changes: 6 additions & 0 deletions expose
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
PORT=8000
if [ "$1" != "" ]; then
PORT=$1
fi
python3 -m http.server $PORT
6 changes: 6 additions & 0 deletions gen_passwd
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
LEN=16
if [ "$1" != "" ]; then
LEN=$1
fi
head -n 1 /dev/urandom | base64 | grep -o '[[:alnum:]]' | head -n $LEN | tr -d '\n'
2 changes: 2 additions & 0 deletions git_change_date
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
GIT_COMMITTER_DATE="$1" git commit --amend --no-edit --date "$1"
2 changes: 2 additions & 0 deletions git_commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
git commit -m "$(curl -s http://whatthecommit.com/index.txt)"
10 changes: 10 additions & 0 deletions installer
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

mkdir /tmp/utils-installer
cd /tmp/utils-installer
wget https://github.com/fabiocicerchia/utils/archive/master.zip
unzip master.zip && rm master.zip
cd utils-master/
rm installer *.*
cd /tmp/utils-installer/utils-master /opt/utils-master
echo "PATH=\$PATH:/opt/utils-master" | tee -a /etc/profile
2 changes: 2 additions & 0 deletions ip_location
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
curl "http://ip-api.com/line/$1?fields=country,countryCode,city"
2 changes: 2 additions & 0 deletions ip_public
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
curl ifconfig.me
2 changes: 2 additions & 0 deletions mac_random
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'
3 changes: 3 additions & 0 deletions pdf_compress
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
FILE=$1
pdf2ps $FILE $FILE.ps && ps2pdf $FILE.ps $FILE && rm $FILE.ps
24 changes: 24 additions & 0 deletions server_specs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh
IS_NIX=$(which free)
echo "Arch: $(arch)"
if [ $IS_NIX ]; then
echo "CPU: $(nproc 2> /dev/null)"
echo "RAM: $(free -m 2> /dev/null | grep Mem | awk '{print $2}') MB"
echo "Swap: $(free -m 2> /dev/null | grep Swap | awk '{print $2}') MB"
else
echo "CPU: $(sysctl -n hw.physicalcpu)"
echo "RAM: $(echo $(($(sysctl -n hw.memsize) / 1024 / 1024))) MB"
echo "Swap: $(sysctl vm.swapusage | awk '{print $4}' | sed 's/\..*//') MB"
fi

echo "Disk: $(df -h / | tail -n1 | awk '{print $3}')"
echo "Avg load: $(uptime | sed 's/.*: //')"
if [ $IS_NIX ]; then
echo "IP Private: $(ip addr show eth0 | grep "inet\b" | head -n1 | awk '{print $2}' | cut -d/ -f1)"
else
echo "IP Private: $(ifconfig en0 | grep "inet\b" | head -n1 | awk '{print $2}' | cut -d/ -f1)"
fi

IP=$(curl -s ifconfig.me)
echo "IP Public: $IP"
echo "Location: $(curl -s http://ip-api.com/line/$IP?fields=country)"
2 changes: 2 additions & 0 deletions stealth
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
unset HISTFILE
3 changes: 3 additions & 0 deletions timestamp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
TIME=$1
date -d@$TIME 2> /dev/null || date -r $TIME

0 comments on commit c00e40b

Please sign in to comment.