Vamos a instalar el paquete wiringpi2:
apt-get update
apt-get install python-dev python-pip
pip install wiringpi2
Nos conectamos a python e importamos el módulo:
python
import wiringpi2
wiringpi2.piBoardRev()
apt-get update
apt-get install python-dev python-pip
pip install wiringpi2
python
import wiringpi2
wiringpi2.piBoardRev()
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
Trigger = 10
Echo = 12
GPIO.setup(Trigger,GPIO.OUT)
GPIO.setup(Echo,GPIO.IN)
print "Sensor Ultrasonico"
try:
while True:
GPIO.output(Trigger,False)
time.sleep(0.5)
GPIO.output(Trigger,True)
time.sleep(0.00001)
GPIO.output(Trigger,False)
inicio=time.time()
while GPIO.input(Echo)==0:
inicio=time.time()
while GPIO.input(Echo)==1:
final=time.time()
t_transcurrido=final-inicio
distancia=t_transcurrido*34000
distancia=distancia/2
if distancia < 10:
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(16, GPIO.OUT)
GPIO.output(16,1)
else:
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(16, GPIO.OUT)
GPIO.output(16,0)
except KeyBoardInterrupt:
GPIO.cleanup()
CRITICAL: (0, 'Socket error: [Errno 111] Connection refused')
root@kali:/home# /etc/init.d/apache2 start
[....] Starting apache2 (via systemctl): apache2.service
. ok
root@kali:~# visudo
# User privilege specification
www-data ALL=(ALL:ALL) NOPASSWD: ALL
root@kali:~# su - www-data
www-data@kali:~$
www-data@kali:~$ sudo cd /var/www/html/
www-data@kali:~/html$ sudo vi prende.py
#!/usr/bin/python
print "LED prendido!!"
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(17, GPIO.OUT)
GPIO.output(17,1)
www-data@kali:~/html$ sudo vi prende.php
$a=exec('sudo python /var/www/html/prende.py');
echo $a;
?>
www-data@kali:~/html$ sudo vi apaga.py
#!/usr/bin/python
print "LED apagado!!"
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(17, GPIO.OUT)
GPIO.output(17,0)
www-data@kali:~/html$ sudo vi apaga.php
$a=exec('sudo python /var/www/html/apaga.py');
echo $a;
?>
www-data@kali:~/html$ sudo vi boton.php
root@kali:~# cd /var/www/html/
root@kali:/var/www/html# git clone https://github.com/rpi-jefer/rpi-led
root@kali:~# vi /var/www/html/rpi-led/procesa.php
root@kali:~# apt-get install python-dev python3-dev gcc
root@kali:/home# wget https://pypi.python.org/packages/e2/58/ 6e1b775606da6439fa3fd1550e7f71 4ac62aa75e162eed29dbec684ecb3e /RPi.GPIO-0.6.3.tar.gz
root@kali:/home# tar xzvf RPi.GPIO-0.6.3.tar.gz
root@kali:/home# cd RPi.GPIO-0.6.3
root@kali:/home/RPi.GPIO-0.6.3# python setup.py install
root@kali:~# python
Python 2.7.13 (default, Jan 19 2017, 14:48:08)
[GCC 6.3.0 20170118] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import RPi.GPIO
root@kali:/home# vi prender_led.py
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(17, GPIO.OUT)
GPIO.output(17,1)
root@kali:/home# vi apagar_led.py
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(17, GPIO.OUT)
GPIO.output(17,0)
root@kali:/home# python prender_led.py
root@kali:/home# python apagar_led.py
root@kali:/home# vi prende_Con_1_Apaga_con_0.py
import RPi.GPIO as GPIO
import sys
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
LED=17
print sys.argv[1]
ESTADO=int(sys.argv[1])
GPIO.setup(LED, GPIO.OUT)
GPIO.setwarnings(False)
if ESTADO == 0:
print('Apagando el LED')
GPIO.output(LED,ESTADO)
else:
print('Prendiendo el LED')
ESTADO = 1;
GPIO.output(LED,ESTADO)
root@kali:/home# python prende_Con_1_Apaga_con_0.py 1
root@kali:/home# python prende_Con_1_Apaga_con_0.py 1
root@kali:/home# vi SOS.py
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
while 1:
GPIO.setup(17,GPIO.OUT)
GPIO.output(17,1)
time.sleep(0.5)
GPIO.setup(17,GPIO.OUT)
GPIO.output(17,0)
time.sleep(0.5)
GPIO.setup(17,GPIO.OUT)
GPIO.output(17,1)
time.sleep(0.5)
GPIO.setup(17,GPIO.OUT)
GPIO.output(17,0)
time.sleep(0.5)
GPIO.setup(17,GPIO.OUT)
GPIO.output(17,1)
time.sleep(0.5)
GPIO.setup(17,GPIO.OUT)
GPIO.output(17,0)
time.sleep(0.5)
GPIO.setup(17,GPIO.OUT)
GPIO.output(17,1)
time.sleep(2)
GPIO.setup(17,GPIO.OUT)
GPIO.output(17,0)
time.sleep(0.5)
GPIO.setup(17,GPIO.OUT)
GPIO.output(17,1)
time.sleep(2)
GPIO.setup(17,GPIO.OUT)
GPIO.output(17,0)
time.sleep(0.5)
GPIO.setup(17,GPIO.OUT)
GPIO.output(17,1)
time.sleep(2)
$ sudo su - root
# fdisk -l |grep NTFS
# mount /dev/sda3 /mnt/
# cd /mnt/Windows/System32/
# cp -pf sethc.exe sethc.exe.origY luego lo pisamos con el cmd.exe:
# cp -pf cmd.exe sethc.exe
# reboot
C:\Windows\System32> control userpasswords2
root@kali:~# lsusb
root@kali:~# vi /etc/network/interfaces
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-ssid "Mi_Nombre_de_la_Red"
wpa-psk "La_clave_para_Conectar"
root@kali:~# /etc/init.d/networking restart
root@kali:~# vi /etc/network/interfaces
auto wlan0
#allow-hotplug wlan0
#iface wlan0 inet dhcp
iface wlan0 inet static
address 192.168.1.43
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
wpa-ssid "Nombre_Wifi"
wpa-psk "Contraseña"
root@kali:~# /etc/init.d/networking restart
root@linuxillo:~# nmap -sP 192.168.1.0-255 | grep -2 Raspberry | head -1
root@kali:~# apt-get update
root@kali:~# apt-get install x11vnc
Do you want to continue? [Y/n] Y
root@kali:~# x11vnc -storepasswd
Enter VNC password:
Verify password:
Write password to /root/.vnc/passwd? [y]/n y
Password written to: /root/.vnc/passwd
root@kali:~#
root@kali:~# x11vnc -ncache q0 -auth guess -nap -forever -loop -repeat -rfbauth /root/.vnc/passwd -rfbport 5900