My Tech Note's

Categoria: Sem categoria (Page 1 of 2)

TextBelt A free, open source API for outgoing texts.

TextBelt

A free, open source API for outgoing texts.

Maintained by Ian Webster. Open source on github.

TextBelt is a REST API that sends outgoing SMS. It is available as a public service or as an internally self-hosted server.

Textbelt uses carrier-specific gateways to deliver your text messages for free, and without ads. The service is fairly reliable and has sent over 1 million texts.

Send a text with a simple POST request:

 

Simple PHP contact form with Google reCaptcha

So, *everyone* needs a simple form to send emails, via PHP, but we also need a protection agains bots/spammers.
This is code that i’v grabbed from codeforgeek and improved since the original had a few errors that made it impossible to run/work/send email.

It uses Google reCaptcha and you need to register you site/domain on it and grab the site key and the secret key.

The form already has twitter bootstrap classes… but you can remove them! :)

The form.php – at the begin
<?php
	$to      = '[email protected]';
	$subject = 'Support Message';

	// keys from Google reCaptcha https://www.google.com/recaptcha/admin
	$sitekey = 'recaptcha_site_key';
	$secretkey = 'recaptcha_secret_key';

	$alert = '';
	if ($_SERVER['REQUEST_METHOD'] == 'POST')
	{
		$email;$message;$captcha;
		if(isset($_POST['email']))
        			$email=$_POST['email'];
		        if(isset($_POST['message']))
        			$message=$_POST['message'];
			if(isset($_POST['g-recaptcha-response']))
        		$captcha=$_POST['g-recaptcha-response'];

	        	if(!$captcha)
        		$alert = '<div class="alert alert-warning" role="alert">Please wait until the captcha protection give you a check mark.</div>';

        	$response=json_decode(file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret='.$secretkey.'&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']));

		if($response->success==false)
		{
			/* lets set the error message for the alert... */
			if ($alert=='')
				$alert = '<div class="alert alert-danger" role="alert">Some how you have been detected has a spammer.</div>';
        	}
		else
		{
			/* the email to you */
			$headers = 'From: '.$to.'' . "\r\n" .
                	'Reply-To: '.$email.'' . "\r\n" .
                	'X-Mailer: PHP/' . phpversion();
            		mail($to, $subject, $message, $headers);
			/* the copy of the email to the *client* */
			$headers = 'From: '.$email.'' . "\r\n" .
				'Reply-To: '.$to.'' . "\r\n" .
				'X-Mailer: PHP/' . phpversion();
			mail($email, 'COPY - '. $subject, $message, $headers);
			/* lets set the success message for the alert... */
			$alert = '<div class="alert alert-success" role="alert">Your email has been sent.</div>';
        	}
	}
?>
The html form
<?=$alert?>
<form id="comment_form" action="" method="post">
	<input name="email" type="email" placeholder="Type your email" size="40" class="form-control" value="<[email protected]$email?>" ><br><br>
	<textarea name="message" rows="8" cols="39" class="form-control"  placeholder="Your message to us..." ><[email protected]$message?></textarea><br>
	<div class="g-recaptcha" data-sitekey="<?=$sitekey?>"></div><br>
	<input type="submit" name="submit" value="Send message" class="btn btn-default"><br>
</form>

Some where at the bottom/footer…

<script src='https://www.google.com/recaptcha/api.js'></script>

 

Hope it helps anyone! :)

Esoterica – acesso externo ao MySQL em alojamentos partilhados

Em ‘tuguês…
básicamente é o seguinte:

Boa tarde,

Informamos que o acesso externo ao MySQL em alojamentos partilhados Esoterica encontra-se bloqueado por questões de segurança.

A gestão da base de dados deverá ser efectuado através do phpMyAdmin disponível no painel de controlo da sua conta de alojamento.

Se necessitar de esclarecimentos adicionais não hesite em contactar-nos.

Cumprimentos,

Setting up my MOTD on a Ubuntu 14.04.3 LTS

Some of my servers have a fancy motd…
I like them… unfortunately my new server didn’t had it.

I had to run

apt-get install landscape-common
dpkg-reconfigure landscape-common

On dkpg-reconfigure I’v selected Run sysinfo on every login.

Welcome to Ubuntu 14.04.3 LTS (GNU/Linux 3.13.0-63-generic x86_64)

* Documentation: https://help.ubuntu.com/
You have new mail.
Last login: Fri Oct 23 10:28:37 2015 from es2-84-XXX-XXX-XXX.netvisao.pt

System information as of Fri Oct 23 10:28:59 CEST 2015

System load: 0.06 Processes: 245
Usage of /: 81.9% of 411.33GB Users logged in: 1
Memory usage: 9% IP address for em0: 195.154.XXX.XXX
Swap usage: 0%

Graph this data and manage this system at:
https://landscape.canonical.com/
[email protected]:~$

To have the number of updates/security updates we need to run the following apt-get command….

sudo apt-get install update-notifier-common

This way we will see also

20 packages can be updated.
8 updates are security updates.

11354348_10153193542464733_1315224652_n

Howto make tunnel with iproute

Machine A has ip address 192.168.56.101
Machine B has ip address 192.168.56.102

You can call your tunnel whatever you like and i will  call for example tl0.

Machine A

ip tunnel add tl0 mode ipip remote 192.168.56.102 local 192.168.56.101
ip link set tl0 up
ip addr add 10.10.10.1/24 dev tl0

Machine B

ip tunnel add tl0 mode ipip remote 192.168.56.101 local 192.168.56.102
ip link set tl0 up
ip addr add 10.10.10.2/24 dev tl0

On machine A

[email protected]:~# ping 10.10.10.2
PING 10.10.10.2 (10.10.10.2) 56(84) bytes of data.
64 bytes from 10.10.10.2: icmp_req=1 ttl=62 time=0.403 ms
64 bytes from 10.10.10.2: icmp_req=2 ttl=62 time=0.397 ms
^C
— 10.10.10.2 ping statistics —
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.397/0.400/0.403/0.003 ms

[email protected]:~# ping 10.10.10.1
PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data.
64 bytes from 10.10.10.1: icmp_req=1 ttl=62 time=0.403 ms
64 bytes from 10.10.10.1: icmp_req=2 ttl=62 time=0.397 ms
^C
— 10.10.10.1 ping statistics —
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.397/0.400/0.403/0.003 ms

and its works, but insecure 🙁

Howto convert rrd files between architectures

While migrating cacti over to a new virtual machine I’ve got “ERROR: This RRD was created on another architecture” when generate new graph
you need convert  all rrd files from  32bit to 64bit.
On the 32 bit machine in <directory_cacti>/rra/ and run then:

for i in `find ./ -type f -name “*.rrd” -print`; \
do \
rrdtool dump $i > $i.xml; \
done

Copy all xml files to the other 64b machine, and put on same location and run then on 64b machine:

for i in `ls *.xml`; \
do \
rrdtool restore $i `echo $i |sed s/.xml//g`; \
done

Tutorial: make tunnel secure between two linux boxe’s

This example is based on two boxe’s debian, Client and Server

 

explain

 

Note: box1 has ip address 1.2.3.5 and box2 has ip address 1.2.3.4

  1. Install the package stunnel on both servers
    $ apt-get install -y stunnel
  2. configure the stunnel config on client box
    $ vim /etc/stunnel/stunnel.conf
    cert = /etc/ssl/certs/stunnel.pem
    chroot = /var/lib/stunnel4/
    setuid = stunnel4
    setgid = stunnel4
    pid = /stunnel4.pid
    ;socket = l:TCP_NODELAY=1
    ;socket = r:TCP_NODELAY=1
    debug = 7
    output = /var/log/stunnel4/stunnel.log
    client = yes[boxserver]
    accept = 127.0.0.1:1234
    connect = 1.2.3.4:1234
  3. configure the stunnel config on server box
    vim /etc/stunnel/stunnel.conf
    cert = /etc/ssl/certs/stunnel.pem
    chroot = /var/lib/stunnel4/
    setuid = stunnel4
    setgid = stunnel4
    pid = /stunnel4.pid
    ;socket = l:TCP_NODELAY=1
    ;socket = r:TCP_NODELAY=1
    debug = 7
    output = /var/log/stunnel4/stunnel.log
    client = yes[boxserver]
    accept = 1234 
    connect = 127.0.0.1:4321
  4. start the service on both servers
    $ service syslog-ng start
  5. check connection
    $ netstat -antp | grep 1234
  6. to test with one simple message
    – On the server box (to listen)
    $ nc -p 1234 -l
    – On the client box
    $ ( echo “Test msg”;  echo “Test the second message”; ) | nc 127.0.0.1 1234
  7. check on the server box, and you will see the messages
  8. And now, you are ready to setup por exeample syslog between box’s linux

VirtualBox on OS-X Host – howto mount a external USB drive

you can't mount the external usb drive, because the permission on /dev/vboxdrv

To check usb's devices, and u can check if the external stroage are available or not.

$ VBoxManage list usbhost

Manufacturer: JMicron
Product: Storage

Current State: Unavailable

This mean, the VirtualBox doesnt have permssion.

 

To resolv this issue:

you need manipulating the permission on /dev/vboxdrv, so open the terminal

1) sudo su –

2)  unload the kernel extension:

kextunload -b com.apple.iokit.IOUSBMassStorageClass

3) change the group and set permission

after:

# ls -lah /dev/vboxdrv
crw——- 1 root wheel 36, 0 Jan 25 19:22 /dev/vboxdrv

 chgrp vboxusers /dev/vboxdrv
 chmod g+rw /dev/vboxdrv

before:

# ls -lah /dev/vboxdrv
crw-rw—- 1 root admin 36, 0 Jan 25 19:22 /dev/vboxdrv

4) load the kernel extension:

kextload com.apple.iokit.IOUSBMassStorageClass

 

After the procedure, u can mount the external storage on virtual machine.

 

« Older posts

© 2020 Sec&Stuff&Others

Theme by Anders NorenUp ↑