Skip to content

Instantly share code, notes, and snippets.

@e23z
e23z / webserver_setup.sh
Last active July 25, 2017 14:40
[SQLInjection Vulnerable Server Setup] A simple bash script to install to prepare a vulnerable lamp server for educational purposes. #scripts #lamp #ubuntu #learning #demo
#!/bin/bash
PWD=$(pwd)
CURDIR=$(dirname "$(readlink -f "$0")")
GROUP=$(ls -ld ~ | awk '{print $4}')
USER=$(ls -ld ~ | awk '{print $3}')
IP=$(ifconfig | grep -Pi 'inet\saddr:.+bcast' | awk '{print $2}' | sed 's/addr://g')
clear
cd ~
echo "Precisamos de permissão de root para alguns comandos."
read -p 'Digite sua senha de usuário: ' PASSWORD
@e23z
e23z / protect.py
Last active July 25, 2017 14:41
[Index File Generator] Simple python script to create "index.html" files in all subdirectories of a given directory to avoid directory listing and other things in a webserver. #scripts #utils #security
import os, sys
if len(sys.argv) == 1:
print('Please, specify a directory!')
else:
root = sys.argv[1]
dirs = [x[0] for x in os.walk(root)]
for _ in dirs:
if _ != '.' and _ != root and '/.git' not in _:
filepath = _ + '/index.html'
@e23z
e23z / elastic.sh
Last active July 26, 2017 13:01
[ElasticSearch Install & Config] Script to install elasticsearch on a Ubuntu 16.04 server and configure the service cluster. #scripts #elasticsearch #configuration #ubuntu
#!/bin/bash
clear
cd ~
read -s -p 'Sudo password: ' PASSWORD
echo ""
echo $PASSWORD | sudo -Sk apt-get update
sudo apt-get install -y software-properties-common
sudo add-apt-repository -y ppa:webupd8team/java
sudo apt-get update
sudo apt-get -y install oracle-java8-installer
@e23z
e23z / crackr.py
Last active October 19, 2017 13:16
[Password Crackr] A python script to crack the password of zip files. #scripts #password #security #utils #whitehacking
from multiprocessing import Process, Queue
import zipfile
import datetime
import shutil
import argparse
import os
class Crackr:
buffer_size = 1024000
@e23z
e23z / identify_focus_thief.py
Created July 25, 2017 14:56
[Focus Monitor] A python script to monitor and display which app is capturing the focus of your mac screen. #utils #scripts #macos
#!/usr/bin/python
from AppKit import NSWorkspace
import time
t = range(1,100)
for i in t:
time.sleep(3)
activeAppName = NSWorkspace.sharedWorkspace().activeApplication()['NSApplicationName']
print(activeAppName)
@e23z
e23z / report-ping.awk
Created July 25, 2017 15:02
[Linode Speedtest] Script to test Linode response & download speed. #scripts #test #utils #linode
#!/usr/local/bin/awk -f
BEGIN {
printf "host\tloss\trtt min\tavg\tmax\tstddev\n"
}
/^---/ {
split($2, a, ".")
printf "%s\t", a[2]
}
@e23z
e23z / hardening.sh
Created July 25, 2017 15:08
[Ubuntu 16.04 Server Hardener] A script to make it easy to harden an Ubuntu 16.04 server. Its purpose is to setup simple security measures out-of-the-box, not to apply advanced security measures. #scripts #security #configuration #utils
#!/bin/bash
cd ~
read -s -p 'Sudo password: ' PASSWORD
echo ""
echo "Configuring server..."
read -p "What's the hostname of this machine? " NEW_HOSTNAME
echo $PASSWORD | sudo -Sk hostnamectl set-hostname $NEW_HOSTNAME
sudo sed -i -e "s/^127.0.0.1.*$/127.0.0.1 localhost $NEW_HOSTNAME/g" /etc/hosts
sudo dpkg-reconfigure tzdata
sudo service cron restart
@e23z
e23z / mysql_installer.sh
Created July 25, 2017 15:14
[MySQL Install & Config] A simple script to install and configure MySQL on a Ubuntu 16.04 server. #scripts #mysql #server #configuration
#!/bin/bash
clear
cd ~
read -s -p 'Sudo password: ' PASSWORD
echo ""
echo $PASSWORD | sudo -Sk sudo apt-get update
echo "Installing mysql..."
sudo apt-get install -y mysql-server-5.7
echo "Securing mysql instalation..."
sudo mysql_secure_installation
@e23z
e23z / join.cs
Last active August 7, 2017 21:24
[Linq left outer join] #linq #csharp #entityframework #database
from table1 in _repository1
join table2 in _repository2 on table1.column equals table2.column into tmp
where table1.column == null
select new { Object1 = table1, Object2 = tmp.DefaultIfEmpty( ).FirstOrDefault( ) }
@e23z
e23z / remote_ipaddress.cs
Last active July 25, 2017 18:23
[Remote IpAddress .NET Core] How to get the client remote ip address with .net core. #csharp #tips #mvc #netcore
public string RemoteIp => _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString();