Easy Host Fake Win32
Sometimes we want to redirect some host to another ip address, the quick option is edit the hosts file.
Well i made this tool to do that.
Java Desktop Application, needs Java RunTime:
Easy Host Fake Java Setup
Is my first Java desktop application on NetBeans
PHP5 script, needs Console Getopt Pear Package (getopt function don’t work on Windows, in the next php 5.3.0 could be)
need pear? run go-pear.bat on your php5 directory
c:\>pear install Console_Getopt
Windows Batch file:
:save this ehf.cmd on your %windir%
:set php-cli to your php.exe path
@ set php- cli=c:\php5\php.exe
:set ehf script path
@ set ehf=c:\develop\php\scripts\ehf.php
@% php- cli% % ehf% % 1 % 2 % 3 % 4
Script ehf.php:
/* Script: Easy Host Fake
* Author: Albertux (Alberto Isaac Ayala Esquivias)
* WebSite: http://Albertux.AyalaSoft.com
* FeedBack: <albertoi7@gmail.com>
* License: GPLv3 (http://www.gnu.org/licenses/gpl.txt)
* Note: you need Pear Package Console Getopt
*/
$ip_default = '127.0.0.1' ; // default ip
$hosts_file = 'c:/windows/system32/drivers/etc/hosts' ; // default hosts file
require_once 'Console/Getopt.php' ;
$options = Console_Getopt:: getopt ( $_SERVER [ "argv" ] , "a:e:r:" ) ;
function about( ) {
echo "
Easy Host Fake (version 1.0.1) [2008-12-27]
Usage: ehf [OPTIONS]
Mandatory: \" -r\" or \" -e\" [host]
Options:
-r [host] [redirect host to 127.0.0.1 (or other ip address)]
-e [host] [erase host on hosts file]
-a [ip address]
Examples:
ewf -r google.com -a 192.168.1.1
ewf -e google.com
More info [http://Albertux.AyalaSoft.com/2008/12/28/easy-host-fake-win32/]
" ;
}
function AddHost( $host , $ip ) {
global $hosts_file ;
$handle = fopen ( $hosts_file , "a" ) ;
fwrite ( $handle , "\r \n $ip\t $host\t # Easy Host Fake" ) ;
fclose ( $handle ) ;
}
function removeHost( $host ) {
global $hosts_file ;
$handle = fopen ( $hosts_file , "r" ) ;
$contents = fread ( $handle , filesize ( $hosts_file ) ) ;
fclose ( $handle ) ;
$pattern = '/\\ r\\ n(\d+)\.(\d+)\.(\d+)\.(\d+)\t' . $host . '\t# Easy Host Fake/' ;
$replacement = "" ;
$newcontents = preg_replace ( $pattern , $replacement , $contents ) ;
$handle = fopen ( $hosts_file , "w" ) ;
fwrite ( $handle , $newcontents ) ;
fclose ( $handle ) ;
}
function getValue( $data , $var ) {
for ( $i = 0 ; $i < count( $data [ 0 ] ) ; $i ++ ) {
if ( $var == $data [ 0 ] [ $i ] [ 0 ] ) {
break ;
}
}
return $data [ 0 ] [ $i ] [ 1 ] ;
}
if ( $options -> message ) { about( ) ; die ( ) ; }
$host = getValue( $options , "r" ) ;
$ip = getValue( $options , "a" ) ;
if ( ! $host ) {
$host = getValue( $options , "e" ) ;
if ( $ip ) { about( ) ; die ( ) ; }
if ( ! $host ) { about( ) ; die ( ) ; }
removeHost( $host ) ; die ( ) ;
}
if ( ! $host ) { about( ) ; die ( ) ; }
if ( ! $ip ) { $ip = $ip_default ; }
addHost( $host , $ip ) ;
Download php script + batch cmd
Note: on Windows Vista you need some permissions on hosts file, and remember all Web browsers use cache.
network , projects , security , web , windows
java , pear , php , tool
Tcl scripting and SQLite
Tcl tutorial
Download Tcl/Tk (source/binary)
SQLite API (tclsh)
Download SQlite (source/binary)
A simple example (taken from sqlite.org):
#!/usr/bin/tclsh
if {$argc!=2} {
puts stderr "Usage: %s DATABASE SQL-STATEMENT"
exit 1
}
load /usr/lib/tclsqlite3.so Sqlite3
sqlite3 db [ lindex $argv 0]
db eval [ lindex $argv 1 ] x {
foreach v $x ( * ) {
puts "$v = $x($v)"
}
puts ""
}
db close
database , develop , projects , security , windows
sqlite , tclsh
Win32 Installers
Sometimes you need to distribute your program to another computers one option is make a installer
Nullsoft Scriptable Installer System (WebSite )
You are Delphi/Pascal developer ?
Inno setup Compiler (WebSite )
You want quick and easy installer, without scripting language ?
Little Install Builder (WebSite )
If you are on Visual Studio you can use publish wizard on build menu.
develop , windows
tool
TODO LIST 2009
Read/Learn/Practice:
Python 2.6 (What’s New )
Perl 5 (Modules , Packages )
PHP (Changes , and news)
COBOL
.NET (C#, LINQ, (ok VB but not much))
Java (Im interested on Mobil Applications)
Haskell
Ruby (Im interested on Rails)
Parrot and Pugs
Gnu/Linux (Services and Bash)
BSD and OpenSolaris
Personal Projects 2009:
BSE (Blog’s Search Engine) (http://BSE.AyalaSoft.com )
Invoices PHP (Now is part of a Intranet) (http://valuacion.com.mx )
Forming one’s own business
And others ….
Lambda Functions on PHP 5.3.0:
$lambda = function ( ) { echo "Hello World!\n " ; } ;
Parrot “Hello World” example:
.sub main
print "Hello World!\n " ;
.end
COBOL “Hello World” example:
* Hello World Program
* GPL Copyleft Jonathan Riddell 2001
IDENTIFICATION DIVISION .
PROGRAM-ID . hello.
ENVIRONMENT DIVISION .
DATA DIVISION .
PROCEDURE DIVISION .
DISPLAY "Hello ," WITH NO ADVANCING
DISPLAY "World!"
STOP RUN .
Haskell “Hello World” example:
develop , unix/linux , web , windows
cobol , dotnet , haskell , java , perl , python , ruby
C Compile on Demand
If you want to use C/C++ as CGI you need compile the code you can compile on demand check C Cod WebSite
See the Documentation some aspects similars to ASP(VBScript).
you now:
#!/usr/bin/php
#!/usr/bin/perl
#!/usr/bin/python
#!/bin/bash
...
Add this #!/usr/bin/ccod to use C/C++, one simple example:
Download C Cod.
develop , network , projects , unix/linux , web , windows
c/c++ , cgi
Instant Boot (ASRock Inc)
Instant Boot is a pretty cool product of ASRock Inc , you can boot on Windows Vista only in 4 seconds.
See the video:
Download (see the model of the motherboard).
hardware , windows
tool , win32
XAMPPLITE MINI CONTROL
Using the XAMPPLITE sometimes i have a little trouble with xampp-control.exe to start or stop Apache and MySQL so I decide to make a small program.
Here the source code to compile it in VB.NET 2008:
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
Public Class Form1
Private Sub Button1_Click( ByVal sender As System.Object , ByVal e As System.EventArgs ) Handles Button1.Click
xampplite.run_services ( )
End Sub
Private Sub Button2_Click( ByVal sender As System.Object , ByVal e As System.EventArgs ) Handles Button2.Click
xampplite.stop_services ( )
End Sub
End Class
Module xampplite
Sub run_services( )
run_batch( "C:\xampplite\apache_start.bat" )
run_batch( "C:\xampplite\mysql_start.bat" )
End Sub
Sub stop_services( )
run_batch( "C:\xampplite\apache_stop.bat" )
run_batch( "C:\xampplite\mysql_stop.bat" )
End Sub
Sub run_batch( ByVal x As String )
Dim psi As New ProcessStartInfo
psi.FileName = x
psi.WorkingDirectory = "C:\xampplite\"
psi.WindowStyle = ProcessWindowStyle.Hidden
Process.Start ( psi)
End Sub
End Module
develop , windows
dotnet , vb.net , win32
Recent Comments