20
Sep
Written by: ame235

You should know about VNC. Google it, that is perfect for small business when you are away.
1st: you have to make computer users sign document mentioning the fact “computer in use might be monitored for administration purposes” (I do use it only for administration purposes!)
Now the server is pretty simple to setup. and still you can Google that. (pay attention to the fact there are lots of virus friendly vnc servers. so choose one wisely!)
my trick: each server streams on one port: for access from the outside i configured the router to forward connection to each port to the right IP. (PC’s have fixed IP’s)
If you don’t like to pay for dynamic DNS like me or get bored with account expiration then you should use my solution:
From the outside, how do i know what IP the router has?

Next file goes on a webserver..it’s used to return the address of the viewer. (So when you will ask for it after it will retur the IP of the machine asking)

1
2
3
4
5
6
<?php
/**
 * Returns the IP of the viewer
 */
echo $_SERVER['REMOTE_ADDR'];
?>

Next file has to be run as cron each hour (or less or more..) o a machine of the business network.
it checks getvisitor.php on a webserver and creates a php file returning the ip of the router.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
#  This is 235 script. no guarantees
#  © Ame235.
#___________________________________________
 
externalip=`wget -q -O /dev/stdout http://www.yoursite.com/getvisitorip.php`
 
# create php answering file
#/////////////////////////////////////
echo "<?php" > tmp_file0.txt
echo "\$val = \$_GET['req'];" >> tmp_file0.txt
echo "if (\$val == \"getip\"){" >> tmp_file0.txt
echo "	print(\"$externalip\");" >> tmp_file0.txt
echo "}" >> tmp_file0.txt
echo "?>" >> tmp_file0.txt
 
# SEND AS A PHP FILE TO ONLINE FTP SERVER
#/////////////////////////////////////
ftp -invp ftp.yourftp.fr<<ENDFTP
	user USER PASSWORD
	bin
	lcd folder_on_local_station
	put tmp_file0.txt web/secu.php
	bye
ENDFTP
 
# REMOVE TEMP FILE
#/////////////////////////////////////
rm tmp_file0.txt
 
exit 0

so from the outside, to get to vnc from my mac, i use this AppleScript,
shows a list of available machines, then on selection gets IP of the router from secu.php created before, and connects to that address using tightvnc.jar

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
-- ame235© script
on StartVnc(theHost, thePort)
	try
		set mypath to path to me as string
		set AppleScript's text item delimiters to ":"
		set the item_list to every text item of mypath
		set num3 to count item_list
		set num3 to num3 - 1
		set AppleScript's text item delimiters to "/"
		set list2 to items 2 thru num3 of item_list
		set mypath to the list2 as string
 
		set shell2 to "java -jar '/" & mypath & "/VncViewer.jar' host " & theHost & " port " & thePort & " password xxx 'JPEG image quality' 3 'Restricted colors' yes 'View only' yes"
		do shell script shell2	
	end try
	return 0	
end StartVnc
 
set choices to {"one", "two", "three"}
set answer to (choose from list choix with prompt "Which terminal you whant to connect to? :" without multiple selections allowed) as text
if answer is not "false" then
	set theIP to do shell script "curl -s 'http://www.XXX.com/secu.php?req=getip'"
	if answer is equal to "one" then
		StartVnc(theIP, 3900)
	end if
	if answer is equal to "two" then
		StartVnc(theIP, 4900)
	end if
	if answer is equal to "three" then
		StartVnc(theIP, 5900)
	end if
end if

and finally you will need to put vncviewer.jar in same folder as the AppleScript
get it here: http://www.tightvnc.com/download.html

obviously this is very simple to implement in another situation/environment.
You can for example imagine to put this on an autorun usbKey:
By plugging it in, the batch (*.bat file: the windows bash scripting but very limited) starts setting up the vnc server and the autorun for ip retrieving. there are commands to do this silently.
I had this file in my USBKey, unfortunately it was a 16Gb CHINESE key…well after 200 write/rewrite it blow up. literally.
maybe I’ll rewrite one.




18
Sep
Written by: ame235

I Love the net, because i can always Google something when i need information about it.
Sometimes i get lazy and totally copy works.. but i never forget to give credits to authors.
(Unless i mod everything) and You should do the same.

Today i activated a plugin named “Plugins List” For WordPress.
(in About section) It gives the list of active plugins used on my WordPress Blog.

Get it Here:
Plugins List by Davide Benini




This one returns a random article from Wikipedia FR.
It has some bugs, because of html chars and simplicity…
but at least it’s fast and reliable.

user@computer:$ curl -s "http://fr.wikipedia.org/w/index.php?title=`curl -s -L "http://fr.wikipedia.org/wiki/Sp%C3%A9cial:Page_au_hasard" | grep "<title>" | sed -e :a -e 's/<[^>]*>//g;/</N;//ba' | sed 's/ - Wikipédia//g' | sed -e 's/^[ \t]*//' | sed 's/ /_/g'`&printable=yes" | grep "<p>" | sed -e :a -e 's/<[^>]*>//g;/</N;//ba'

http://fr.wikipedia.org/wiki/Sp%C3%A9cial:Page_au_hasard > is a random page redirector from wikipedia
-L option in curl allows redirection from there. (Location)
then we get the title of page, replace spaces with underscores and finally get a printable URL.
after that we keep only “<p>” lines (usually text in wikipedia)

Again it’s not perfect. feel free to make it better and post it back here ;)