June 3, 2010

Cisco AnyConnect in Ubuntu & Fedora – Fixing it the Easy way

Cisco AnyConnect fails to properly connect under Linux (Ubuntu and Fedora were tested) due to the following reason:

connection attempt has failed due to a server certificate problem

Eventually I found a fix for it, and while it worked it was a slight pain in the ass as it required you to download and extract firefox from Mozilla.com, pull files from the archive, copy them, and create softlinks. I created a simple script (and a folder that contains the needed files) that will resolve this issue in no time flat. Simply:

  1. Download the archive
  2. Extract the archive: tar -xvzf cisco_anyconnect_fix.tar.gz
  3. Go into the newly created folder: cd cisco_anyconnect_fix
  4. Execute the script as root: sudo anyconnect_fix.sh
  5. Connect to VPN as normal

I hope this works for you, I did test it in Ubuntu 10.04 & Fedora 13 with success. There is a check that will install via yum or aptitude the needed libraries.

Give it a try and let me know if you run into any issues.

Download (1MB): cisco_anyconnect_fix.tar.gz

March 20, 2008

Bypass Torrent File Network Filters

Many Universities, workplaces, etc are starting to take action against the use of torrent files. You can always change ports so port blocking is a worthless use of network time. However, places have started to restrict the ability to download files ending in the .torrent extension. This complicates things immensely.

Take for example a situation I encountered. On the Ubuntu 7.10 release date it was nearly impossible to find a server to download the ISO from as they were all getting hammered with requests. The solution many servers displayed was ‘download via a torrent’. When I tried that on my university network, I encountered the problem, I couldn’t download the .torrent file. This was annoying, as the University states that using the network to download and seed legal torrents is allowed. How did I get passed this? Using a simple php script I coded up, that can be found at http://steve.blogme.us/bypass.php

The script simply takes the URL to the .torrent file, saves it on the local server as a text file, and allows you to then download it, then all you need to do is change the extension to .torrent and load it up in the torrent client. It is that simple, and it works! Enjoy.

November 13, 2007

PHP Sessions – Quick and dirty

A session variable is a great way to store information about visitors on your site. For example if a user logs in you could store their username, and the date of login as session variables, then add a file include that checks to make sure the user is logged in before viewing a page.

Below is example code using session variables:

1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
echo "Creating session variables... <br />";
$_SESSION['uname'] = "Steve";
$_SESSION['pass']  = "MyPassword";
echo "Displaying session data... <br />";
echo $_SESSION['uname'] . "<br />" . $_SESSION['pass'] . "<br />";
echo "Destroying session data... <br />";
unset($_SESSION['uname']);
unset($_SESSION['pass']);
echo "Displaying session data again (should be empty)... <br />";
echo $_SESSION['uname'] . "<br />" . $_SESSION['pass'] . "<br />";
echo "Done! <br />";
?>

That code, when run will output:

Creating session variables...
Displaying session data...
Steve
MyPassword
Destroying session data...
Displaying session data again (should be empty)...

Done!

The code is very simple to follow, $_SESSION[] variables are created named uname and pass, values are assigned to them and displayed via echo. Then unset() is used to delete the values, thus when echoing the output again the lines are blank. Cake.

November 10, 2007

PHP Generated iPhone User Images

I have been screwing around with some PHP using functions like imagecreatefrompng() and ImagePNG() to create a few images that create a ‘signature’ image that can be used on websites, etc.

Image 1:

Useage:

Forums: [img]http://www.rapidhash.com/rapidhash/autosig.php.png[/img]

Image 2:

Useage:

Forums: [img]http://www.rapidhash.com/rapidhash/iphone.php.png[/img]

Image 1 will just display the IP of the user. Image 2 will display the users IP, Browser, and Operating System.

Feel free to use them if you desire where ever you want. Just link to them (do not try to save the image, it will not work if you do).

Enjoy.

November 6, 2007

Track your site activity in PHP

Want to know who is visiting your website, when the peak times are, and how people are finding you? It is a lot easier than it sounds. While the code below may be over-simplified, it does get the job done. The code assumes that you have a include in your main source file that opens a database connection, and a code at the end of your source file that closes it.

The code will get the referring page, the date and time of access, and the IP of the users and store it in a table called tracker. You can then easily code a interface to view that database information. Later I will post code for an interface to this data.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
// very simple PHP function, call when database connection is open using tracker();
// By Steve Morrissey
 
function tracker()
{
	$referer = $_SERVER["HTTP_REFERER"];
	$time = date("F j, Y, g:i a");
	$ip = $_SERVER['REMOTE_ADDR'];
	if($referer == "")
	{
	     $referer = "Direct hit";
	}
	mysql_query("INSERT INTO tracker (id, referer, ip, accessed) VALUES('', '$referer', '$ip', '$time')") or die(mysql_error());
} // end tracker
?>
October 8, 2007

Good Method for Unique ID’s?

Here is a function I am making to handle user registration for a new project. Take a look at the else statement, think it will do the trick? All comment’s are private to not publicly expose hack-a-able errors. Let me know, thanks.

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
	function doRegistration()
	{
		if($this->validation->run() == FALSE)
		{
			$this->load->view('regform');
		}
		else
		{
			if(!$_POST)
			{
				/**
				 * We should never get here, this means that
				 * someone tried to access the page without
				 * filling out the form, signs of a usual hack
				 * attempt. We should deny access at this point
				 * or perhaps implement a 3 strike ban system
				 * based on IP address
				 */
				$this->load->view('regform');
			}
			else
			{
				$email = $_POST['email'];
				$pass  = $_POST['password'];
				$date  = date("m.d.y");
 
				/**
				 *	$id is generated using the following:
				 *	Month Day Hour Minute Second
				 *	IE: If it is June 18th 2008 at 11:53:33 AM the ID is:
				 *	06182008115333 (14 characters). This virtually eliminates
				 *	the chances that two people will have duplicate ID's.
				 *	What are the chances two people will access the site to register at
				 *	the EXACT time down to the milisecond? Not likely.
			     */
				$id    = date("mdyais");
 
				$sql = "SELECT * FROM some_table WHERE email = ?";
				$query = $this->db->query($sql, array('$email'));
				if($query->num_rows() > 0)
				{
					// We have a existing entry for that email address, not good.
					// Kick back an error page.
				}
				else
				{
					$data = array('id' => '', 'email' => $email, 'pass' => $pass, 'date' => $date);
					$str = $this->db->insert_string('accounts', $data);
					$query = $this->db->query($str);
				}	
			} // end if !$_POST
		}
	} // end doRegistration