ThisisLegal.com

ThisisLegal Forums

Welcome to the forums! A chance for site members to chat and get help.

You are not logged in.

#1 2008-03-10 17:10:44

DarkMunk
Member
Registered: 2007-09-17
Posts: 17

Python Snippets

Some more silly Python snippets I did when bored. They're shit I know but it killed four minutes of my boring life.

Simple Random Password Generator

#! /usr/bin/env python

# Simple password generation script
# Copyright H1 Programming 2008.
# Written by DarkMunk
impor­t random

print "Type G and press enter to generate a password"
option = raw_input();
if option == "G":
	#Generate Password
	password = str(random.randint(1000000000,2000000000))
	password = password.replace('1', 'g')
	password = password.replace('2', 'Z')
 	password = password.replace('3', 't')
  	password = password.replace('4', 'A')
   	password = password.replace('5', 'gY')
    	password = password.replace('6', 'p')
     	password = password.replace('7', 'Q')
      	password = password.replace('8', 'u')
       	password = password.replace('9', 'M')
	password = password.replace('0', 'l')
	print password
elif option != "G":
	#Don't generate password
	print "I said G mofo!"

Is Alive? (Checks whether you can connect to a host on a certain por­t)

#! /usr/bin/env python

#IsAlive - This script checks whether the target host is online or not
#This basically a test script, use how you want
#Written by DarkMunk for H1 Programming Python Snippets section

impor­t socket
impor­t sys
mySocket = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
print "Enter host IP"
hostIP = raw_input()
print "Enter host por­t"
hostPort = int(raw_input()) 

   
try:
    mySocket.connect ( ( hostIP, hostPort ) )
    print "Host Online"
    mySocket.close
except:
    print "Host not online"

Lol, boredom.

Offline

#2 2008-03-11 05:55:52

t0mmy9
Administrator
Registered: 2005-01-07
Posts: 21

Re: Python Snippets

I like the isalive one, simple but works


Site admin

Offline

#3 2008-03-12 06:23:24

DarkMunk
Member
Registered: 2007-09-17
Posts: 17

Re: Python Snippets

Yeah, I didn't think it would be that simple to do something like that. It's also the base code for my port scanner, which still needs fixing lol.

Offline

#4 2008-03-13 17:31:22

sOwL
Member
Registered: 2007-09-16
Posts: 97

Re: Python Snippets

great work on that second part, im waiting to see the port scanner. honestly this post made me googling for python tongue

PS: i noticed this on ur post: /usr/bin/env python ... i see your running linux. gj there smile


withstupid

Offline

#5 2008-03-14 06:39:57

DarkMunk
Member
Registered: 2007-09-17
Posts: 17

Re: Python Snippets

Thanks. And yep, Linux rules biggrin I actually burned my win xp disk after i'd got linux set up biggrin

Offline

#6 2008-03-15 13:43:14

sOwL
Member
Registered: 2007-09-16
Posts: 97

Re: Python Snippets

thats called justice biggrin


withstupid

Offline

#7 2008-03-16 04:09:54

t0mmy9
Administrator
Registered: 2005-01-07
Posts: 21

Re: Python Snippets

hahahah nice


Site admin

Offline

Board footer

Powered by FluxBB