Posted by root
Sun, 28 Sep 2008 19:09:00 GMT
host_port = ARGV[0]
host = host_port.split(':').first
port = host_port.split(':').last
puts %x[nmap -p #{port} #{host}]
Or just:
host, port = ARGV[0].split(':')
puts %x[nmap -p #{port} #{host}]
Usage (cli and given that the script is named scan_proxy):
./scan_proxy 202.105.182.87:808
Posted in Ruby, scripts | Tags scanner | no comments | no trackbacks
Posted by root
Sat, 20 Sep 2008 14:39:00 GMT
class Hash
def search(arg)
self.select { |k,v| k =~ /#{arg}/ or v =~ /#{arg}/ }
end
end
search = ARGV[0]
search =~ /^[0-9]+/ and search = search.to_i
phones = {
"me" => "359880101020406",
"Hitler" => "+49 666",
"Van Gog" => "+31",
"devil" => "666",
"God" => "1",
}
phones.search(search).each do |person|
print "person:#{person.first}\tnumber:#{person.last}\n"
end
Posted in Ruby, scripts | no comments | no trackbacks
Posted by root
Mon, 04 Aug 2008 08:41:00 GMT
alias _rmdir_empty='rmdir * 2>/dev/null'
Posted in scripts | Tags shell | no comments
Posted by root
Fri, 01 Aug 2008 05:58:00 GMT
Sample .bashrc file:
alias d2b='ruby -e "puts ARGV.first.to_i.to_s(2)"'
alias d2h='ruby -e "puts ARGV.first.to_i.to_s(16)"'
alias d2o='ruby -e "puts ARGV.first.to_i.to_s(8)"'
alias b2d='ruby -e "puts eval(%q|0b| + ARGV.first)"'
alias b2h='ruby -e "puts eval(%q|0b| + ARGV.first).to_s(16)"'
alias b2o='ruby -e "puts eval(%q|0b| + ARGV.first).to_s(8)"'
alias h2d='ruby -e "puts eval(%q|0x| + ARGV.first)"'
alias h2b='ruby -e "puts eval(%q|0x| + ARGV.first).to_s(2)"'
alias h2o='ruby -e "puts eval(%q|0x| + ARGV.first).to_s(8)"'
alias o2d='ruby -e "puts eval(%q|0o| + ARGV.first)"'
alias o2b='ruby -e "puts eval(%q|0o| + ARGV.first).to_s(2)"'
alias o2h='ruby -e "puts eval(%q|0o| + ARGV.first).to_s(16)"'
Posted in Ruby, scripts | Tags alias | no comments | no trackbacks
Posted by root
Sat, 26 Jul 2008 21:46:00 GMT
Posted in scripts | Tags vampire | no comments
Posted by root
Sat, 19 Jul 2008 21:59:00 GMT
require 'tempfile'
require 'net/http'
arg = ARGV[0].chomp
url = 'sa.dir.bg'
h = Net::HTTP.new(url, 80)
resp,data = h.get("/cgi/sabig.cgi?word=#{arg}", nil )
outtmp = Tempfile.new("translator")
outtmp << data.to_s
outtmp.rewind
puts %x[html2text "#{outtmp.path}"]
Posted in scripts | Tags tools | no comments
Posted by root
Tue, 08 Jul 2008 00:26:00 GMT
Go to your TRAC project dir and issue the following commands:
1. cd to_your_trac_project_dir
2. ruby -i -pe ’$_.sub! /(repository_dir\s=\s).+/, “repository_dir = NEW_repository_PATH”’ trac.ini
3. trac-admin . resync
Posted in scripts | Tags SA | no comments
Posted by root
Mon, 16 Jun 2008 12:49:00 GMT
mkdir -p $1 && cd $1 && $SHELL
Posted in scripts | Tags SA | no comments
Posted by root
Sat, 22 Mar 2008 18:45:00 GMT
OS users:
users = File.new("/etc/passwd").collect{|x| x.split(':')[0]}
Number of files in directory:
puts %x{ls}.split(/\n/).size
puts %x[ls|wc].split(/\s+/)[1]
Network interfaces:
inet = Hash.new{|h,k| h[k.split(/\s/)[0]] = k.scan(/addr:(\d+\.\d+\.\d+\.\d+)/)[0].to_s}
%x[ifconfig].to_s.split("\n\n").collect{|x| inet[x]}
to be continued….
Posted in Ruby, scripts | Tags administration | no comments
Posted by root
Fri, 22 Feb 2008 21:23:00 GMT
use strict;
use warnings;
my $dom = shift || die "missing name\n";
my $res = qx{whois $dom};
die $1 . "for '$dom'\n" if $res =~ /(no\s+whois\s+server\s+)/i;
die "$dom is free\n" if $res =~ /no\s+match|does\s+not\s+exist/i;
die "$dom is reserved\n";
Posted in Perl, scripts | Tags money | no comments