Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Sunday, July 29, 2007

Turn on syntax highlight in vim

This really annoys me! Every time I used vim, I have to turn on syntax highlight and numbering etc manually. And I can't find .vimrc in my home directory, only .viminfo is there. Here is how to get it solved,

create a .vimrc in your $HOME directory,
vim ~/.vimrc
then put all the statements
syntax on
set number
set wrapmargin=1
set background =
...
Now syntax highlighter and numbering are on, yo....

Wednesday, May 09, 2007

Online reverse lookup sites

Ripped from kuza55 blog, I thought this may come in handy.


" http://kuza55.blogspot.com/2006/10/online-reverse-lookup-tables-for.html

md5:
http://www.tmto.org/ (formerly md5lookup.com)
http://md5.rednoize.com (good with words)
http://nz.md5.crysm.net (English dictionary, nearly all one to four character alphanumeric. 27.8m records.) - seems to be down atm
http://us.md5.crysm.net (British, Jargon and American worldlist, IP addresses 16.0m records)
http://www.xmd5.org (good with numbers)
http://gdataonline.com (wordlist based, I think)
http://www.hashchecker.com (It seems to say its good, but I've never gotten many hits form here)
http://passcracking.ru
http://www.milw0rm.com/md5
http://plain-text.info (this one is quite good and generally returns results, but you have to submit things to be cracked, its not just an online database)
http://www.securitystats.com/tools/hashcrack.php (does various, including LM NTLM and SHA-1, but seems to return no results on anything than the most basic, so rather useless)
http://www.schwett.com/md5/ - Does Norwegian words too
http://passcrack.spb.ru/
http://shm.pl/md5/
http://www.und0it.com/
http://www.neeao.com/md5/
http://md5.benramsey.com/
http://www.md5decrypt.com/
http://md5.khrone.pl/
http://www.csthis.com/md5/index.php
http://www.md5decrypter.com/
http://www.md5encryption.com/
http://www.md5database.net/
http://md5.xpzone.de/
http://md5.geeks.li/
http://www.hashreverse.com/
http://www.cmd5.com/english.aspx
http://www.md5.altervista.org/
http://md5.overclock.ch/biz/index.php?p=md5crack&l=en
http://alimamed.pp.ru/md5/ (for those who can't read russian: put your md5 in the second box)
http://md5crack.it-helpnet.de/index.php?op=add (German, I have no idea....)
http://cijfer.hua.fi/ (Projects->md5 reverse lookup)
http://shm.hard-core.pl/md5/
http://www.mmkey.com/md5/HOME.ASP
http://www.thepanicroom.org/index.php?view=cracker
http://rainbowtables.net/services/results.php (I'm not sure i'd trust this site to give more than a tiny amount of results)
http://rainbowcrack.com/ (requires people to contribute rainbowtables to be able to query them, and continue contributing them constantly)
http://www.securitydb.org/cracker/
http://passwordsecuritycenter.com/index.php?main_page=product_info&cPath=3&products_id=7 (This is meant to be used as proof that they can actually reverse passwords to convince you to buy their stuff, but as long as they decrypt it it doesn't matter why, right?)
http://0ptix.co.nr/md5
https://www.astalavista.net/?cmd=rainbowtables
http://ice.breaker.free.fr/
http://www.md5this.com
http://www.pldsecurity.de/forum/md5.php
http://www.xeons.net/genesis/
http://hackerscity.free.fr/
http://bisix.cogia.net/
http://md5.allfact.info/
http://bokehman.com/cracker/
http://www.tydal.nu/article/md5-crack/
http://ivdb.org/search/md5/
http://md5.netsons.org/
http://md5.c.la/ (The form at the bottom left of the page)
http://www.jock-security.com/md5_database/?page=crack
http://c4p-sl0ck.dyndns.org/cracker.php
http://www.blackfiresecurity.com/tools/md5lib.php (Queries the MD5 Library AIM Bot)
http://www.md5-db.com/index.php

lm Only:
http://lasecwww.epfl.ch/~oechslin/projects/ophcrack/ (Currently Offline)
http://www.milw0rm.com/lm (Currently Offline)

lm + ntlm:
http://plain-text.info
http://www.securitystats.com/tools/hashcrack.php
http://rainbowtables.net/services/results.php
http://rainbowcrack.com/
http://passwordsecuritycenter.com/index.php?main_page=product_info&cPath=3&products_id=7
https://www.astalavista.net/?cmd=rainbowtables

md4:
http://www.securitystats.com/tools/hashcrack.php
http://rainbowtables.net/services/results.php
http://rainbowcrack.com/

sha1:
http://passcrack.spb.ru/
http://www.hashreverse.com/
http://rainbowcrack.com/
http://www.md5encryption.com/
http://www.shalookup.com/
http://md5.rednoize.com/
http://c4p-sl0ck.dyndns.org/cracker.php
http://www.tmto.org/

"

Thursday, December 14, 2006

Finish your work more efficiently

With linux's built in tool, we can do our work more efficiently. For instance, we want to create 50 user directories, tons way can do the task.

a perl version:
#!/usr/bin/perl

foreach i (1..50)
{
mkdir("user$_",0744);
# or use the system() function
System(`mkdir user$_");
}

while we can do this with shell, but it only fits :
for i in {1,2,3,4,5,6,7}; do mkdir user$i;done

Perl liner seems to be the best solution for this kind of task (only one line and we can set permission, isn't it great!)

perl -e 'for(1..6) {mkdir("user$_",0744)}'

Of course perl is not only option, python, ruby, C or whatever you like can do a good job. A lot of folks would rather spend whole of time on begging around for 'automated' software, hack up your brain, hack your system, answer is always there for you.

Friday, November 17, 2006

Difference between main()/void main()/int main()/int main(void)/int main(int argc, char *argv[])

I thought this is helpful to novice

From: cprogramming.com

A very common question is "What's the difference between void main and int main?". This particular FAQ tries to answer that and more, covering other versions of the main() implementation.

The first thing to note is that this is one of those topics that people seem to like to argue over for hours, days and more. Some arguments are valid, some are not, and some are just plain old opinion.

The C and C++ standards differ when it comes to main(), so I'll detail each one separately.

For C

Under C89, main() is acceptable, although it is advisable to use the C99 standard, under which only these are acceptable:

int main ( void )
int main ( int argc, char *argv[] )

Slight variations of the above are acceptable, where int can be replaced by a typedef name defined as int, or the type of argv can be written as char ** argv, and so on.

The first option is used when you do not require access to the command line arguments.

The names argc and argv are identifiers that can be changed if you so desire, but sticking to argc/argv is convention.

The return type of main() must always be an int, this allows a return code to be passed to the invoker.

Under C89, the return statement at the end of main() is required, whereas under C99 if no return statement is present, return 0 is implied. However, it is good programming practice to always use a return statement, even if you don't have to.

For C++

The following are acceptable uses:

int main ( int argc, char *argv[] )
int main ()

The first option follows similar conventions to those used by C99.

The second option is used when you do not require access to the command line arguments, and is equivalent to the int main(void) option used by C99.

Again, the return type must always be an int, and the function should return 0; at the end, but it is not required by the standard.

(C) The difference between int main() and int main(void)

A common misconception for C programmers, is to assume that a function prototyped as follows takes no arguments:

int foo();

In fact, this function is deemed to take an unknown number of arguments. Using the keyword void within the brackets is the correct way to tell the compiler that the function takes NO arguments.

What's the deal with void main()

Under regular function calling/returning in C and C++, if your don't ever want to return anything from a function, you define it's return type as void. For example, a function that takes no arguments, and returns nothing can be prototyped as:

void foo(void);

A common misconception is that the same logic can be applied to main(). Well, it can't, main() is special, you should always follow the standard and define the return type as int. There are some exceptions where void main() is allowed, but these are on specialised systems only. If you're not sure if you're using one of these specialised systems or not, then the answer is simply no, you're not. If you were, you'd know it.

Be warned that if you post your "void main" code on the forums, you're going to get told to correct it. Responding with "my teacher said it's OK" is no defence; teachers have a bad habit of being wrong. Be safe, and post only standard code, and you'll find people concentrate on answering your other problems, rather than waste time telling you about this type of thing.

But what about int main(int argc, char *argv[], char *envp[])

As an extension to the guaranteed standard, an additional parameter to main() can, on some systems, be used to gain access to the environment variables. This is isn't guaranteed to work on all compilers, so use it with care if you want to keep your code portable.

And finally, this page gives some more background information as to why void main is bad.

Sunday, October 29, 2006

BlogSpot Profile Hiter

Somehow came across my blog via google, found that only couple hits on my profile pages...hum, this doesn't look good, so I spent 5mins to write up this ugly script to auto hit.(Ooops, I must be bored!)

#!/usr/bin/perl

use LWP;
use strict;

my($usr_agent,$url,$i,$response,$num_hit);

$num_hit = < STDIN>;
$num_hit =~ /\d+/;

$usr_agent = new LWP::UserAgent;
$url="http://beta.blogger.com/profile/14114952655686676020";
$usr_agent->agent("oops");

$i=0;

while($i<$num_hit){

$usr_agent->timeout(25);
$response = $usr_agent->get($url);
++$i;
if($response->is_success){
print "Hit: $i\n";
}
}

Ha, now it has 252 hits....google doesn't need unique ip, or I have to grab bunch proxy which need more work.

Tuesday, October 24, 2006

IE context menu

Ok,create a IE context menu is not new any all.

Credits to old new things (http://blogs.msdn.com/oldnewthing/archive/2004/05/24/140283.aspx)
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\Context_Name
@="c:\\path\file.htm"

Then we can do funky things in html page,you can use common scripting language like javascript, vbscript to manipulate functions.

< script language="Javascript">
var fac = prompt("Factor",100);
external.menuArguments.document.body.style.zoom=fac+"%";
< /script>

As you see external is the object,with menuArguments method to do zooming.An alternative method is make a external object, port it as dll file or use your binary to output a html....Your design!

End? No yet, from a user's point of view, there might be some anonying malware injected into his/her IE, think about how to contrust a context menu?There you go, go to registry and delete the keys, also keep an eye on what lib it relies on(usually locates at HKCR\{id}), delete its lib as well. In fact, this is how some popluar anti-malware works (e.g:spybot), if you are designing similar software, it is worthwhile to dig into registry, the core of windows.

p.s: An interesting method by willij3 presents a shorter and neat hack
http://www.rpi.edu/~willij3/hacks/IEContextMenu_Reg.txt

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt]

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\&Dictionary.com]
@="javascript: open('http://www.dictionary.com/cgi-bin/dict.pl?term=' + external.menuArguments.document.selection.createRange().text,\"dictionary\");"
"Contexts"=dword:00000010

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\&Google]
@="javascript: open('http://www.google.com/search?q=' + external.menuArguments.document.selection.createRange().text,\"google\");"
"Contexts"=dword:00000010

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\&Open In New Window]
@="javascript: open(external.menuArguments.document.selection.createRange().text);"
"Contexts"=dword:00000010

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\&Search Slashdot]
@="javascript: open('http://slashdot.org/search.pl?query=' + external.menuArguments.document.selection.createRange().text,\"/.\");"
"Contexts"=dword:00000010

Sunday, October 22, 2006

Password generator II

My last post about password generator , Warpboy's wordlistGenerator present an more effective way for looping.

alphanumeric
my $var = (('A'..'Z'),(1-9));

mixalpha
my $var = (('A'..'Z'),('a'..'z'));

upperAlpha
my $var = ('A'..'Z');

lower Alpha
my $var= ('a'..'z');

lalpha-smybol
my @var = (('a'..'z') ,(0..9),'!','@','#','$','%','^','&','*','(',')','-','_','+','=');

digit
my $var=(1..9);

all
my @char = (('A'..'Z'), (0..9),'!','@','#','$','%','^','&','*','(',')','-','_','+','=','~','`','[',']','{','}','|', "/", ":" ,";",'"',"'",'<','>',",",".","?","/");

My code:
for($i=65;$i<=122;$i++){ print ","; print "\"".chr($i)."\""; } Then the rest of his idea is fairly simple and nice $charset = chomp(); #get user desired charset...if($charset eq 'charset_name')

$inputted = chomp(); #number of words to generate
$len = Length(); #word length
$ran = $#var +1; #counter

foreach(1..$inputed){
for(1..int($a)){
$p=$char[int(rand($ran))];
print pa $p; #pa - file handler
}
}

His code is avaiabel http://www.securitydb.org/Warpboy/WordlistGenerator.rar
Cool...perl is really a great programming language with strong flexiblity and rich modules, I love it ~~



Saturday, October 21, 2006

How to add your site or your favorite side to firefox sidebar search engine

You're a firefox fan? You're a webmaster or web developer? Ever want to add a customized search engine to firefox (top-right) side-bar? Great! Then this tip(not a new technique at all) is for you. Here is the instruction of how:

First you need to create a 16x16 pixels png image (as search engine icon)
Second, make a file.src as the following structure
version="" #version number
name="" #engine name e.g:Google
description=""
method="" #Get/Post
action="" #search url, where the html form goes
searchform=""
queryEncoding='' #This field is optional, e.g:ISO-8859-1
queryCharset='' #This field is optional, e.g:ISO-8859-1
>

#parameter(s)
< input name="" user>
< /search>

update="" #url to get the lastest src file
updateIcon="" #url to get the lastest src file
updateCheckDays="" #datatype: int
>

Easy,hum! Of course, before you perform the above steps, make sure you website or your favorite site has a search engine. Finally, put this script into a page(locally or remotely)

function addEngine(name,ext,cat)
{
if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function"))
{
var url=""; #your url
window.sidebar.addSearchEngine(
url+name+".src",
url+name+"."+ext,
name,cat );
}
else
{
document.write("oops,error");

}
}

javascript:addEngine('title','image_format','search_category')
More info at http://mycroft.mozdev.org/deepdocs/installing.html#manual

In case you get tired of it, simply remove the src and png.
Profile Folder can be found at here

Thursday, October 19, 2006

password generator

Wrote dictionary generator script for brute force my route passwd...I know I can use C4S3y's module to make the whole work easier and make some cool script, but I just want to get my hands dirty and review a little bit perl script...
#!/usr/bin/perl

# Author: insistkool
# Date: Oct-19-2006
# Purpose: password generator - Upper and Lower Case
use strict;
use Getopt::Std;

#The for loop here is to create a alpha lists

#for(1..9){
# print ",";
# print "\"".$_."\"";
#
#}
#
#for($i=65;$i<=90;$i++){
# print ",";
# print "\"".chr($i)."\"";
#
#}
#
#for($a=97;$a<=122;$a++){
# print ",";
# print "\"".chr($a)."\"";
#
#}



my @chars =("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P",
"Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i",
"j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","1","2",
"3","4","5","6","7","8","9");

my ($x,$y,$z,$a,$b,$c,$dict,%opts);

getopts('h:o:', \%opts);

if(defined($opts{'o'})) {
$dict = $opts{'o'};
}
else {
$dict = "dict.txt";
}

if(defined($opts{'h'})) {
usage();
}

sub usage{
print "Usage: $0 -o dict.txt\n";
print " \t -h man page\n";
print "If output file is not specified, it will be saved to dict.txt\n";
exit 31337;
}

open(dict,">$dict");


for($x=0;$x<@chars;$x++){
for($y=0;$y<@chars;$y++){
for($z=0;$z<@chars;$z++){
for($a=0;$a<@chars;$a++){
print dict "$chars[$x]$chars[$y]$chars[$z]$chars[$a]\n";
}
}
}
}
print "Check $dict!\n";
close(dict);

Saturday, October 07, 2006

Server Probing

Here is Server Probing script from somewhere, pretty nice...
Of course, Server Spy can do this , but the idea basically functions the same
perl $0 > server

#!/usr/bin/perl -W
use strict;
use IO::Socket;

my @hosts=qw(www.google.com www.foundstone);

sub go{
my $server=shift;
print "Processing Server probing ...\n";
my $socket=new IO::Socket::INET(PeerAddr=$server,
PeerPort='80';
Proto='tcp');
$socket or die "\n unable to connect to the $_:$!";
print $socket "GET / HTTP/1.1\r\n\r\n";
while($socket){
if(/^Server:\s*(.*)/){
print "$server:$1\n";
last;
}
}
}

foreach(@hosts){
go $_;
}

Wednesday, October 04, 2006

Shift and $_

Took me a whiole to figure out what the hell 'shift' and $_ do

my $suck =shift;
print $suck;

[root@rooted_Box]$ perl suck.pl 2
2

my $suck =shift || '192.168.1.1'; //Show 192.168.1.1 if no arg
print $suck;

[root@rooted_Box]$ perl suck.pl
192.168.1.1

my @arr =("a","b","c");
for(@arr){print $_."\n"};

output:
a
b
c

um....perl syntax!!

perl & php exploit template.....

Pretty neat perl exploit template ripped from ezine...

#!/usr/bin/perl

use strict;
use other_modu;

my($host, $port,$shell) = @_;

sub usage{
print "bunch usage";
exit();
}

sub exploit{
}

sub thread{
for my $i(1..MAX_THREAD){
print ".";
my $thread= new Thread \&exploit, $host, $port, $shell
}
}
if(@ARGV < num_argv) {&usage;}else {&exploit;}

and another php exploit template from rgod(i guess)

#!/usr/bin/php -q -d short_open_tag=on; error_reporting(0); //turn off error_reporting, E_ALL when doing debugging ini_set("max_execution_time",0); //execute the script rite away ini_set("default_socket",5); function quick_dump($string){ $result=' ';$eax=' ';$cont= 0; for($i=0;$i<=32 | ord($string[$i] >=126){
{$result.=" .";}
}
else{ $result.=" ".$string[i];}
if(strlen(dechex(ord($string[$i]))==2){
$eax.=" ".dechex(ord($string[$i]));
}
else{
{$exa.=" 0".dechex(ord($string[$i]));}
$cont++;if ($cont==15) {$cont=0; $result.="\r\n"; $exa.="\r\n";}
}
return $exa."\r\n".$result;
}

$proxy_regex = '(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\:\d{1,5}\b)';
function sendpacketii($packet)
{
global $proxy, $host, $port, $html, $proxy_regex;
if ($proxy=='') {
$ock=fsockopen(gethostbyname($host),$port);
if (!$ock) {
echo 'No response from '.$host.':'.$port; die;
}
}
else {
$c = preg_match($proxy_regex,$proxy);
if (!$c) {
echo 'Not a valid proxy...';die;
}
$parts=explode(':',$proxy);
echo "Connecting to ".$parts[0].":".$parts[1]." proxy...\r\n";
$ock=fsockopen($parts[0],$parts[1]);
if (!$ock) {
echo 'No response from proxy...';die;
}
}
fputs($ock,$packet);
if ($proxy=='') {
$html='';
while (!feof($ock)) {
$html.=fgets($ock);
}
}
else {
$html='';
while ((!feof($ock)) or (!eregi(chr(0x0d).chr(0x0a).chr(0x0d).chr(0x0a),$html))) {
$html.=fread($ock,1);
}
}
fclose($ock);
#debug
#echo "\r\n".$html;
}

$url = " ";
$packet="POST ".$url HTTP/1.0\r\n";
$packet.="Content-Type: application/x-www-form-urlencoded\r\n";
$packet.="Host: ".$host."\r\n";
$packet.="Content-Length: ".strlen($data)."\r\n";
$packet.="Connection: Close\r\n\r\n";
$packet.=$data;
sendpacketii($packet);