Skip to content

Instantly share code, notes, and snippets.

View R41D3NN's full-sized avatar

R41D3NN R41D3NN

View GitHub Profile
@R41D3NN
R41D3NN / gist:2791731
Created May 26, 2012 02:10
Prevent Pinterest Pinning on Web Pages
<meta name="pinterest" content="nopin" />
@R41D3NN
R41D3NN / LoginAttemptLogger.sh
Created August 30, 2015 02:37
auth.log Login Attempt Logger
#!/bin/bash
AUTH_LOG=/var/log/auth.log
LOG_FILE=/var/log/login-attempts.txt
IP_ADDR_REGEX='[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\s'
cat $AUTH_LOG | grep -o $IP_ADDR_REGEX | sort | uniq >> $LOG_FILE
cat $LOG_FILE | sort | uniq > $LOG_FILE.tmp
mv -f $LOG_FILE.tmp $LOG_FILE
@R41D3NN
R41D3NN / UnauthorizedLoginAttemptLogger.sh
Created August 30, 2015 02:38
auth.log Unauthorized Login Attempt Logger
#!/bin/bash
AUTH_LOG=/var/log/auth.log
LOG_FILE=/var/log/unauthorized-login-attempts.txt
IP_ADDR_REGEX='[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\s'
cat $AUTH_LOG | grep 'authentication failure' | grep -o $IP_ADDR_REGEX | sort | uniq >> $LOG_FILE
cat $LOG_FILE | sort | uniq > $LOG_FILE.tmp
mv -f $LOG_FILE.tmp $LOG_FILE
@R41D3NN
R41D3NN / UnauthorizedSshAttemptLogger.sh
Last active August 30, 2015 04:17 — forked from jreyes1108/unauthorized ssh attempts
unauthorized ssh attempts
#!/bin/sh
LOG_FILE=/var/log/ssh_complaints.log
AUTH_LOG=/var/log/auth.log
HOSTS_DENY=/etc/hosts.deny
MAX_ATTEMPTS=8
(
#WHITELIST="127.0.0.1 192.168.110.1 `host test.net.com | sed -e 's/[^0-9]*//'`"
WHITELIST="127.0.0.1"
@R41D3NN
R41D3NN / get-ipinfo.js
Last active May 21, 2023 00:51
Javascript for retrieving IP Address info using ipinfo.io API via AJAX.
var GetIpInfo = function(ipAddr) {
var info = null;
var infoUrl = "http://ipinfo.io/" + ipAddr;
$.ajax({
url: infoUrl,
type: 'GET',
dataType: 'json',
async: false,
success: function(data) {
info = data;
@R41D3NN
R41D3NN / convert_sha1_hostkey_digest_base64_to_hex.sh
Created February 14, 2017 18:45
Get the hex representation of a public key from base64 format.
awk '{$print $2}' id_xxx.pub | openssl base64 -d -A | openssl sha1
@R41D3NN
R41D3NN / ApplyWindowsEventLogPermissions.ps1
Created March 30, 2017 16:58
Very simple script to apply permissions to Windows Event Log.
$username = "IIS APPPOOL\Identity"
Function Set-PermissionsForEventLogSecurity($username)
{
$registryKeyPath = "HKLM:\SYSTEM\CurrentControlSet\Services\EventLog\Security"
$acl = Get-Acl $registryKeyPath
$inherit = [System.Security.AccessControl.InheritanceFlags]"ContainerInherit, ObjectInherit"
$propagation = [System.Security.AccessControl.PropagationFlags]"None"
$registryRights = [System.Security.AccessControl.RegistryRights]"QueryValue",
[System.Security.AccessControl.RegistryRights]"EnumerateSubKeys",
@R41D3NN
R41D3NN / Remove-HyperVPXEBoot.psm1
Created May 11, 2017 20:03
Remove the PXE boot sequence from a Hyper-V virtual machine.
Function Remove-HyperVPXEBoot {
<#
.Synopsis
Remove the PXE boot sequence from a Hyper-V virtual machine.
.PARAMETER ComputerName
The name of the Hyper-V computer where the targeted VM is hosted.
.PARAMETER VMName
The name of the Hyper-V virtual machine to remove PXE boot from.
@R41D3NN
R41D3NN / Discovery--Computers-and-Total-Local-Accounts.sql
Last active April 25, 2018 00:24
Discovery--Computers-and-Total-Local-Accounts.sql
SELECT
[ou].[DistinguishedName] AS 'OU DN',
[c].[ComputerName],
COUNT([ca].[ComputerId]) AS 'Total Local Accounts',
[CB].[Success],
[CB].[LastErrorMessage]
FROM [tbComputer] [c]
JOIN [tbOrganizationUnit] [ou] ON [c].[OrganizationUnitId] = [ou].[OrganizationUnitId]
LEFT JOIN (SELECT * FROM [tbComputerAccount] [ca] WHERE [ca].[ComputerId] IS NOT NULL) [ca] ON [c].[ComputerId] = [ca].[ComputerId]
CROSS APPLY
@R41D3NN
R41D3NN / Hyper-V--Create-Internal-NAT-Switch.ps1
Created April 18, 2018 15:00
Creates a Hyper-V NAT'd internal switch.
$switchName = "my.local"
New-VMSwitch -SwitchName $switchName -SwitchType Internal
$netAdapter = Get-NetAdapter | Where -Property Name -Eq "vEthernet ($switchName)"
New-NetIPAddress -IPAddress 10.0.0.1 -PrefixLength 24 -InterfaceIndex $netAdapter.ifIndex
New-NetNat -Name "$switchName-NAT" -InternalIPInterfaceAddressPrefix 10.0.0.0/24