Tag Archives: http server

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

Python – Get HTTP Server Information

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

Author: slac3dork
Site: http://snippet.c0de.me
Summary: A python code that will print HTTP Server Response message. For educational purpose only. Tested on Linux.
Usage: python httpserverinfo.py <target_server>

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

import urllib2, sys, re
from time import sleep

def serverInfo(server):
	try:
		print "[-]building request"
		req = urllib2.Request(server)
		sleep(2)
		print "[-]sending request"
		url = urllib2.urlopen(req)
		print "[-]getting information...\n"
		server_info = url.info()
		sleep(2)
		return server_info
	except (urllib2.URLError):
		status = "address not found"
		return status

def welcomeBro():
	print "[+] --------------------------------"
	print "[+] Getting HTTP server infomation"
	print "[+] httserverinfo.py"
	print "[+] Coded By slac3dork"
	print "[+] Greetz to low1z"
	print "[+] --------------------------------\n"

def error():
	print "error bro!"
	print "hey, you don't know how to use this?"
	print "usage: python httpserverinfo.py <target>\n"
	print "target example: http://google.com"

if (__name__ == "__main__"):
	welcomeBro()

	if (len(sys.argv) == 2):
		server = sys.argv[1]
		if (not (re.search("http://", server))):
			server = "http://"+server
		print serverInfo(server)
	else:
		error()



python,logo,banner