Tag Archives: http

Ruby – IP Address to Domain Name

0
Filed under ruby
Tagged as , , , , , , , , , , , , , , , , , , , , , , , ,

Author: slac3dork
Site: http://snippet.c0de.me
Summary: Reverse IP tool. Ruby code to get domain name from ip address and save all results to ip2domain_result.txt. This script need internet connection and create connection to http://www.ip-adress.com/reverse_ip/. Tested on Linux.
Usage: ruby ip2domain.rb <domain_name> or ./ip2domain.rb <domain_name>

#!/usb/bin/ruby

#  _________      .__       .____   _______
# /   _____/ ____ |__|_____ |    |  \   _  \    ____
# \_____  \ /    \|  \____ \|    |  /  /_\  \  / ___\
# /        \   |  \  |  |_> >    |__\  \_/   \/ /_/  >
#/_______  /___|  /__|   __/|_______ \_____  /\___  /
#        \/     \/   |__|           \/     \//_____/
# http://snippet.c0de.me
# slac3dork[at]gmail[dot]com
require 'open-uri'

if ARGV.size < 1
puts '[-] Usage ./ip2domain.rb <ip_address>'
exit 1
end

puts '-----------------------------------------------'
puts '[+] Reverse IP tool'
puts '[+] ip2domain.rb'
puts '[+] Author: slac3dork'
puts "-----------------------------------------------\n\n"

begin
        status = false
        filename = 'ip2domain_result.txt'
        ip_addr = ARGV[0]
        domain_file = File.new("#{filename}", "w")
        open("http://www.ip-adress.com/reverse_ip/#{ip_addr}") {|page|
            page.each_line {|line|
                    if (line =~ /.*<\/td>/)
                            domain_name =  "#{line.slice(/\S.*/).slice(/([a-z0-9_-]+[\.]{1})+[a-z]{2,}/)}"
                            if (domain_name != '')

                                    if (domain_file)
                                            puts "[+] #{domain_name}"
                                            domain_file.puts("#{domain_name}")
                                    else
                                            puts 'Unable to open file'
                                            exit(1)
                                    end

                                    if (!status)
                                            status = true
                                    end

                            end
                    end
                }
           }
        domain_file.close
        if (!status)
                puts '[-] Not found. Check your IP address.'
        else
                puts '--> All domain name results has been saved to ip2domain_result.txt'
        end
rescue OpenURI::HTTPError => error_msg
        puts "[-] Ups! Got bad status code: #{error_msg}. Try again"
rescue Timeout::Error
        puts '[-] oops! Timeout bro, check your internet connection'
rescue Exception => e
        puts "#{e.message}"
end

ruby,code,code,snippet

Python – Twitter bot to update status

0
Filed under python
Tagged as , , , , , , , , , ,

Author: slac3dork
Site: http://snippet.c0de.me
Summary: Twitter bot to update status. You need define your own time interval to tweet and your own messages. This script will update your status randomly within interval. This script for educational purpose only. Tested on Linux.
Usage: python tweethonbot.py -u your_username -p your_password

#!/usr/bin/python
#
#  _________      .__       .____   _______
# /   _____/ ____ |__|_____ |    |  \   _  \    ____
# \_____  \ /    \|  \____ \|    |  /  /_\  \  / ___\
# /        \   |  \  |  |_> >    |__\  \_/   \/ /_/  >
#/_______  /___|  /__|   __/|_______ \_____  /\___  /
#        \/     \/   |__|           \/     \//_____/
# http://snippet.c0de.me
# slac3dork[at]gmail[dot]com  

import urllib, random
from time import sleep, strftime
from optparse import OptionParser

username = ''
passwd = ''
update_uri = ''
interval = 60 # 60 seconds

# message goes here
msg = []
msg.append('twitter is great')
msg.append('I love tweeting')
msg.append('testing...')

# error message vars
con_error = 'Unable to connect. Check your username, password, and internet connection'
exit_msg = 'exiting...'

def init():
	usage = 'usage: %prog -u your_username -p your_password'
	parser = OptionParser(usage=usage)
	parser.add_option('-u', '--user', dest='username',
			help='your twitter username', metavar='your_username')
	parser.add_option('-p', '--password', dest='passwd',
			help='your twitter password', metavar='your_password')

	(options, args) = parser.parse_args()
	if (options.username and options.passwd):
		welcome()
		return options.username, options.passwd
	else:
		parser.print_help()
		exit(1)

def tweet():
	idx = random.randint(0,(len(msg) - 1))
	message = msg[idx]
	tweet_datetime = strftime(" (%Y-%m-%d %H:%M:%S)")

	data = urllib.urlencode({'status':message+tweet_datetime})
	try:
		urllib.urlopen(update_uri, data)
		print 'tweeting at%s' %(tweet_datetime)
	except IOError:
		print con_error
		exit(1)
def bot():
	while True:
		try:
			sleep(interval)
			tweet()
		except KeyboardInterrupt:
			print exit_msg
			exit(0)

def welcome():
	print '------------------------------------'
	print '[+] twitter bot to update twitter status'
	print '[+] tweethonbot.py'
	print '[+] coded by slac3dork'
	print '------------------------------------'

if (__name__ == '__main__'):
	username, passwd = init()
	update_uri = 'http://%s:%s@twitter.com/statuses/update.xml' %(username, passwd)
	bot()





python,logo,banner