Possible HTC M7 Leaked

The net had it first! Well at least possibly! The yet to be released/announced flagship HTC smart phone have leaked. The photo was posted by @evleaks. This phone is likely to be the HTC M7, rumored to have 13 megapixel camera, 4.7-inch 1080p display and is expected to be powered by a 1.7GHz quad-core processor display alongside 2GB RAM. It is said to have a 4.3 ‘ultrapixel’ rear camera and run on Android 4.2 skinned with a layer of the brand new Sense 5.0 UI.

htc-one-leak.jpeg

From this “leaked” photo, it appears that HTC’s new flagship smartphone looks similar to the iPhone 5, the dimensions at least compared to the much bigger and wider current Android phones in the market. Whether this is the HTC M7 or not, we will definitely find out on February 19,2012 at the HTC press event in New York City.

android-phones.JPG

Meanwhile, here’s a quick comparison between the iPhone5 and Blackberry Z10.
More on Possible HTC M7 Leaked

Permalink • Print • Comment

Mikrotik RouterOS Scripting - Automatically find unathorized devices and block it on firewall

mikrotik routeros

One of the features I like most in Mikrotik RouterOS is the ability to run custom scripts that will enable you to automate some things on router side. In a workplace where “bring your own device” is practiced, being able to control the registration of these devices on your network is very important especially for mobile devices - laptops, tablets and smartphones.

It’s becoming harder to control these device especially if they are in large number. Smartphone can be just placed inside a bag or pocket while it automatically connect through your access points where wireless key is known to the user and download unnecessary files on the internet thus wasting network bandwidth while increasing network security risk.

Now, if you happen to have a Mikrotik RouterOS in your network and is facing the same dilemma then probably the script below will help you solve it or least get you started on a better solution.


# Written by: Rex Cortez
# Tested to work on RouterOS 5.19

:foreach i in=[/ip dhcp-server lease find dynamic=yes] do={
   :local dynamicIP [/ip dhcp-server lease get $i address];
   :local dynamicMAC [/ip dhcp-server lease get $i mac-address];
   :local dynamicHOST [/ip dhcp-server lease get $i host-name];
   :local macfound [/ip firewall filter find src-mac-address=$dynamicMAC];

    :if ($macfound != "") do={
        :log info ($dynamicMAC. " already filtered")
    } else= {
        /ip firewall filter add chain=forward src-mac-address=$dynamicMAC action=drop comment=($dynamicHOST . " - " . $dynamicMAC . " Unregistered device")
        :log info ("Added " . $dynamicMAC. " to firewall filter")
    }
}

Basically, the script will look for dynamic ip addresses inside the dhcp server leases table and search their mac address in the firewall filter table. If it’s not yet blocked then it will create an entry blocking the mac address to prevent it from sending traffic through your network.

To automatically execute the script periodically, you will need to add it on the scheduler, see example below:

More on Mikrotik RouterOS Scripting - Automatically find unathorized devices and block it on firewall

Permalink • Print • Comment

Install PHP Pear on Cloud with Linux

php pear installation

I recently got a linux server running on a cloud and migrated few of my sites including this site. However, I forgot that the main page of this site requires DB package to be installed which can be installed through PEAR, and to cut the story short I end up installing PEAR just to get the DB package installed. Below is how to install PEAR on Linux specifically on Ubuntu 12.04.


wget  http://pear.php.net/go-pear.phar

sudo php -q go-pear.phar

Below is a suggested file layout for your new PEAR installation.  To
change individual locations, type the number in front of the
directory.  Type 'all' to change all of them or simply press Enter to
accept these locations.

 1. Installation base ($prefix)                   : /usr
 2. Temporary directory for processing            : /tmp/pear/install
 3. Temporary directory for downloads             : /tmp/pear/install
 4. Binaries directory                            : /usr/bin
 5. PHP code directory ($php_dir)                 : /usr/share/pear
 6. Documentation directory                       : /usr/docs
 7. Data directory                                : /usr/data
 8. User-modifiable configuration files directory : /usr/cfg
 9. Public Web Files directory                    : /usr/www
10. Tests directory                               : /usr/tests
11. Name of configuration file                    : /etc/pear.conf

1-11, 'all' or Enter to continue:
Beginning install...
Configuration written to /etc/pear.conf...
Initialized registry...
Preparing to install...
installing phar:///root/go-pear.phar/PEAR/go-pear-tarballs/Archive_Tar-1.3.7.tar...
installing phar:///root/go-pear.phar/PEAR/go-pear-tarballs/Console_Getopt-1.3.0.tar...
installing phar:///root/go-pear.phar/PEAR/go-pear-tarballs/PEAR-1.9.4.tar...
installing phar:///root/go-pear.phar/PEAR/go-pear-tarballs/Structures_Graph-1.0.4.tar...
installing phar:///root/go-pear.phar/PEAR/go-pear-tarballs/XML_Util-1.2.1.tar...
install ok: channel://pear.php.net/Archive_Tar-1.3.7
install ok: channel://pear.php.net/Console_Getopt-1.3.0
install ok: channel://pear.php.net/Structures_Graph-1.0.4
install ok: channel://pear.php.net/XML_Util-1.2.1
install ok: channel://pear.php.net/PEAR-1.9.4
PEAR: Optional feature webinstaller available (PEAR's web-based installer)
PEAR: Optional feature gtkinstaller available (PEAR's PHP-GTK-based installer)
PEAR: Optional feature gtk2installer available (PEAR's PHP-GTK2-based installer)
PEAR: To install optional features use "pear install pear/PEAR#featurename"

The 'pear' command is now at your service at /usr/bin/pear

** The 'pear' command is not currently in your PATH, so you need to
** use '/usr/bin/pear' until you have added
** '/usr/bin' to your PATH environment variable.

Run it without parameters to see the available actions, try 'pear list'
to see what packages are installed, or 'pear help' for help.

For more information about PEAR, see:

  http://pear.php.net/faq.php
  http://pear.php.net/manual/

Thanks for using go-pear!

Once you have successfully installed PEAR, you can start installing PEAR packages by invoking pear.


pear install DB

That’s about it, let me know should you encounter installation issues with PEAR.

Permalink • Print • Comment

Fetching URL and Sending Post Data on Python

pythong language

Here’s a short simple script on how to fetch URL and sending post data on Python.


#!/path/to/python

import urllib

params = urllib.urlencode({'param1': value1, 'param2': value2})
response = urllib.urlopen("http://www.somewebsite.com/post-data-file.php", params)
html = response.read()

print(html)

That easy :)

Permalink • Print • Comment