Skip to content

Instantly share code, notes, and snippets.

View n1mh's full-sized avatar

Diego Martínez Castañeda n1mh

View GitHub Profile
@n1mh
n1mh / repairing_grub_after_windows10.txt
Last active November 24, 2016 16:03
repairing grub in debian after installing windows 10
# access using netints iso and rescue mode
update-grub2
grub-install /dev/sda
update-grub2
exit
reboot
@n1mh
n1mh / checking_open_ports_with_bash
Created November 30, 2016 09:13
checking open ports using bash
#!/bin/bash
# adapted from:
# https://stackoverflow.com/questions/9609130/quick-way-to-find-if-a-port-is-open-on-linux#9609247
# exec 6<>/dev/tcp/ip.addr.of.server/445
# echo -e "GET / HTTP/1.0\n" >&6
# cat <&6
( exec 6<>/dev/tcp/127.0.0.1/22 && echo 'ssh open!' )|| echo 'ssh closed'
@n1mh
n1mh / 1 check connection from an IP.sh
Last active November 30, 2016 10:26
check connection from an IP
#!/bin/bash
curl -s ifconfig.me
curl -s 'https://api.ipify.org'
curl -s 'http://ipv4bot.whatismyipaddress.com/'
@n1mh
n1mh / getting_linux_distro.sh
Created November 30, 2016 12:20
getting linux distro
#!/bin/bash
if [ "${OS}" = "Linux" ] ; then
KERNEL=`uname -r`
elif [ -f /etc/redhat-release ] ; then
DIST='RedHat'
PSUEDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//`
REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//`
elif [ -f /etc/SuSE-release ] ; then
DIST=`cat /etc/SuSE-release | tr "\n" ' '| sed s/VERSION.*//`
@n1mh
n1mh / launch-wifi-wpa.sh
Created February 10, 2017 09:45
launch wireless connection using wpa_supplicant configuration
#!/bin/bash
sudo wpa_supplicant \
-B \
-iwlan0 \
-c/etc/wpa_supplicant.conf \
-Dwext
sudo dhclient wlan0
sudo ifconfig wlan0
@n1mh
n1mh / device_not_managed.sh
Last active February 13, 2017 14:43
network-manager "device not managed"
#!/bin/bash
sudo sed -i 's/managed=false/managed=true/g' /etc/NetworkManager/NetworkManager.conf
exit 0
@n1mh
n1mh / gist:bcb67cd2203a2d261ac0195f1dafacf0
Created March 1, 2017 13:21 — forked from iLoveTux/gist:c0c6216dca943876da6d
permit insecure connections with urllib2.urlopen in python 2.7.x >= 2.7.9
# Because migrating to python 2.7.9 requires me to update my code (or ask my clients to add cafiles to their trust store
# [which some people don't know how to do]), I found a way to explicitly allow insecure connections (ie. without hostname
# verification) using urllib2.urlopen()
#
# This gist basically involves creating an ssl.SSLContext() with some options which disable hostname verification
# This allows you to, for instance, add a parameter to a function which disables hostname verification.
import ssl
import urllib2
import logging
@n1mh
n1mh / remove_service_systemd.sh
Created March 15, 2017 15:59
remove startup service in systemd
#!/bin/bash
sudo systemctl disable teamviewerd.service
Removed /etc/systemd/system/multi-user.target.wants/teamviewerd.service.
exit 0
@n1mh
n1mh / sed_doble_substitution.sh
Created May 4, 2017 08:32
sed doble substitution
#!/bin/bash
GCC_INSTLLR="https://raw.githubusercontent.com/gecos-team/gecoscc-installer/development/gecoscc-installer.sh"
GCC_VERSION=`curl -s "$GCC_INSTLLR" | grep 'export GECOSCC_VERSION' | cut -d"'" -f2`
GCC_TMPLATE=`curl -s "$GCC_INSTLLR" | grep 'export TEMPLATES_URL' | cut -d'"' -f2 | sed -e 's/$GECOSCC_VERSION/'"$GCC_VERSION"'/'`
# sed 's/xxx/'"$PWD"'/'
echo "Template -> $GCC_TMPLATE"
@n1mh
n1mh / copying_files_rdp_from_linux.sh
Created October 30, 2017 08:49
Copying files using RDP connection from a linux machine
#!/bin/bash
# I've tried to copy files from linux using vinagre (I like it most for RDP connections)
# but it is simplier that rdesktop.
#
# You just have to connect using the option -r disk:share=local_dir and go to a volume
# called 'share in your_machine' and copy the file
/usr/bin/rdesktop 10.10.10.10 -u admin -d myDomain -r disk:share=/home/n1mh/tmp