'Python'에 해당되는 글 105건

  1. 2015.02.07 monitorApache.py
  2. 2015.02.07 rollingDice.py
  3. 2015.02.07 dateTime.py
  4. 2015.02.07 portScanWithBanner.py
  5. 2015.02.07 searchMp3.py
  6. 2015.02.07 findImg.py
  7. 2015.02.06 dateParse.py
  8. 2015.02.06 portScanner.py
  9. 2015.02.06 commandlineFu.py
  10. 2015.02.06 magin8Ball.py
2015. 2. 7. 18:27
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
#! -*- coding: utf-8 -*-

ips={}

fh=open("/var/log/apache2/access.log","r").readlines()
for line in fh:
  ip=line.split(" ")[0]
  if 6 < len(ip) <=15:
    ips[ip]=ips.get(ip,0)+1
print ips




'Python' 카테고리의 다른 글

guessingGame.py  (0) 2015.02.07
logChecker.py  (0) 2015.02.07
rollingDice.py  (0) 2015.02.07
dateTime.py  (0) 2015.02.07
portScanWithBanner.py  (0) 2015.02.07
Posted by af334
2015. 2. 7. 18:19
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

#! -*- coding: utf-8 -*-

import random
min=1
max=6

roll_again="yes"

while roll_again=="yes" or roll_again=="y":
  print "Rolling the dices..."
  print "The values are... "
  print random.randint(min,max)
  print random.randint(min,max)

  roll_again=raw_input("Roll the dices again?")



'Python' 카테고리의 다른 글

logChecker.py  (0) 2015.02.07
monitorApache.py  (0) 2015.02.07
dateTime.py  (0) 2015.02.07
portScanWithBanner.py  (0) 2015.02.07
searchMp3.py  (0) 2015.02.07
Posted by af334
2015. 2. 7. 18:14
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

#! -*- coding: utf-8 -*-

import datetime

now=datetime.datetime.now()

print "-"*25
print now
print now.year
print now.month
print now.day
print now.hour
print now.minute
print now.second

print "-"*25
print "1 week ago was it: ",now-datetime.timedelta(weeks=1)
print "100 days ago was : ", now-datetime.timedelta(days=100)
print "1 week from now it it: ", now+datetime.timedelta(weeks=1)
print "In 1000 days from now is it: ",now+datetime.timedelta(days=1000)

print "-"*25
birthday=datetime.datetime(2015,11,22)
 
print "Birthday in... ", birthday-now
print "-"*25


'Python' 카테고리의 다른 글

monitorApache.py  (0) 2015.02.07
rollingDice.py  (0) 2015.02.07
portScanWithBanner.py  (0) 2015.02.07
searchMp3.py  (0) 2015.02.07
findImg.py  (0) 2015.02.07
Posted by af334
2015. 2. 7. 04:40
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

# -*- coding: utf-8 -*-

import optparse
import socket
from socket import *
def connScan(tgtHost, tgtPort):
  try:
    connSkt=socket(AF_INET, SOCK_STREAM)
    connSkt.connect((tgtHost, tgtPort))
    connSkt.send('AggresivePython\r\n')
    results=connSkt.recv(100)
    print '[+]%d/tcp open'% tgtPort
    print '[+] '+str(results)
    connSkt.close()
  except:
    print '[-]%d/tcp closed'% tgtPort

def portScan(tgtHost, tgtPorts):
  try:
    tgtIP=gethostbyname(tgtHost)
  except:
    print"[-] Cannot resolve '%s':Unknown host" %tgtHost
    return
  try:
    tgtName=gethostbyaddr(tgtIP)
    print '\n[+] Scan Results for: '+tgtName[0]
  except:
    print '\n[+] Scan Results for: '+tgtIP
  setdefaulttimeout(1)
  for tgtPort in tgtPorts:
    print 'Scanning port '+tgtPort
    connScan(tgtHost,int(tgtPort))

def main():
  parser=optparse.OptionParser("usage%prog "+\
      "-H <target host> -p <target port>")
  parser.add_option('-H',dest='tgtHost',type='string', \
      help='specify target host')
  parser.add_option('-p',dest='tgtPort',type='string', \
      help='specify target port[s] separated by comma')
  (options, args)=parser.parse_args()
  tgtHost=options.tgtHost
  tgtPorts=str(options.tgtPort).split(',')
  if(tgtHost==None) | (tgtPorts[0]==None):
    print '[-] You must specify a target host and port[s]'
    exit(0)
  portScan(tgtHost, tgtPorts)
if __name__=='__main__':
    main()


'Python' 카테고리의 다른 글

rollingDice.py  (0) 2015.02.07
dateTime.py  (0) 2015.02.07
searchMp3.py  (0) 2015.02.07
findImg.py  (0) 2015.02.07
dateParse.py  (0) 2015.02.06
Posted by af334
2015. 2. 7. 00:58
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

# -*- coding: utf-8 -*-

import fnmatch
import os

rootPath='/'
pattern='*.mp3'

for root,dirs,files in os.walk(rootPath):
  for filename in fnmatch.filter(files,pattern):
    print(os.path.join(root, filename))



'Python' 카테고리의 다른 글

dateTime.py  (0) 2015.02.07
portScanWithBanner.py  (0) 2015.02.07
findImg.py  (0) 2015.02.07
dateParse.py  (0) 2015.02.06
portScanner.py  (0) 2015.02.06
Posted by af334
2015. 2. 7. 00:57
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

# -*- coding: utf-8 -*-

import fnmatch
import os

images=['*.bmp','*.jpg','*.jpeg','*.png','*,tif','*.tiff']
matches=[]

for root,dirnames,filenames in os.walk("/"):
  for extensions in images:
    for filename in fnmatch.filter(filenames, extensions):
      print os.path.join(root,filename)


'Python' 카테고리의 다른 글

portScanWithBanner.py  (0) 2015.02.07
searchMp3.py  (0) 2015.02.07
dateParse.py  (0) 2015.02.06
portScanner.py  (0) 2015.02.06
commandlineFu.py  (0) 2015.02.06
Posted by af334
2015. 2. 6. 23:44
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

# -*- coding: utf-8 -*-

from datetime import datetime

now =datetime.now()
mm=str(now.month)
dd=str(now.day)
yyyy=str(now.year)
hour=str(now.hour)
mi=str(now.minute)
ss=str(now.second)

print mm+"/"+dd+"/"+yyyy+" "+hour+":"+mi+":"+ss


'Python' 카테고리의 다른 글

searchMp3.py  (0) 2015.02.07
findImg.py  (0) 2015.02.07
portScanner.py  (0) 2015.02.06
commandlineFu.py  (0) 2015.02.06
magin8Ball.py  (0) 2015.02.06
Posted by af334
2015. 2. 6. 23:30
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

# -*- coding: utf-8 -*-

import socket
import subprocess
import sys
from datetime import datetime

#Clear the screen
subprocess.call('clear',shell=True)

#Ask for input
remoteServer= raw_input("Enter a remote host to scan : ")
remoteServerIP=socket.gethostbyname(remoteServer)

#Print a nice banner with information on which host we are about to scan
print "-" *60
print "Please wait, scanning remote host", remoteServerIP
print "-" *60

#Check what time the scan started
t1=datetime.now()

#Using the range function to specify ports (here it will scan all ports between 1 and 1024)
#We also put in some error handling for catching errors

try:
    for port in range(1,5000):
      sock=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
      result=sock.connect_ex((remoteServerIP, port))
      if result==0:
        print "Port {}: \t Open".format(port)
      sock.close()

except KeyboardInterrupt:
  print "You pressed Ctrl+C"
  sys.exit()

except socket.gaierror:
  print 'Hostname could not be resolved, Exiting'
  sys.exit()

except socket.error:
  print "Couldn't connect to server"
  sys.exit()


#Checking the time again
t2=datetime.now()

#Calculates the difference of time, to see how long it took to run the script
total=t2-t1

#Printing the information to screen
print 'Scanning Completed in: ',total





'Python' 카테고리의 다른 글

findImg.py  (0) 2015.02.07
dateParse.py  (0) 2015.02.06
commandlineFu.py  (0) 2015.02.06
magin8Ball.py  (0) 2015.02.06
test_mysql.py  (0) 2015.02.06
Posted by af334
2015. 2. 6. 23:07
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
# -*- coding: utf-8 -*-

import urllib2
import base64
import json
import os
import sys
import re

os.system("clear")
print "-" *80
print "Command Line Search Tool"
print "-"*80

def Banner(text):
  print "="*70
  print text
  print "="*70
  sys.stdout.flush()

def sortByVotes():
  Banner('Sort By Votes')
  url="http://www.commandlinefu.com/commands/browse/sort-by-votes/json"
  request=urllib2.Request(url)
  response=json.load(urllib2.urlopen(request))
  #print json.dumps(response, indent=2)
  for c in response:
    print "-" * 60
    print c['command']

def sortByVotesToday():
  Banner('Printing All commands the last day (Sort By Votes)')
  url="http://www.commandlinefu.com/commands/browse/last-day/sort-by-votes/json"
  request=urllib2.Request(url)
  response=json.load(urllib2.urlopen(request))
  for c in response:
    print "-"* 60
    print c['command']

def sortByVotesWeek():
  Banner('Printing All commands the last week (Sort By Votes)')
  url="http://www.commandlinefu.com/commands/browse/last-week/sort-by-votes/json"
  request=urllib2.Request(url)
  response=json.load(urllib2.urlopen(request))
  for c in response:
    print "-" * 60
    print c['command']

def sortByVotesMonth():
  Banner('Printing: All commands from the last months (Sorted By Votes) ')
  url="http://www.commandlinefu.com/commands/browse/last-month/sort-by-votes/json"
  request=urllib2.Request(url)
  response=json.load(urllib2.urlopen(request))
  for c in response:
    print "-" * 60
    print c['command']


def sortByMatch():
    #import base64
    Banner("Sort By Match")
    match=raw_input("Please enter a search commands: ")
    bestmatch=re.compile(r' ')
    search =bestmatch.sub('+',match)
    b64_encoded=base64.b64encode(search)
    url="http://www.commandlinefu.com/commands/matching/"+search+"/"+b64_encoded+"/json"
    request=urllib2.Request(url)
    response=json.load(urllib2.urlopen(request))
    for c in response:
      print "-"*60
    print c['command']

print """
1.Sort By Votes (All time)
2.Sort By Votes (Today)
3.Sort By Votes (Week)
4.Sort By Votes (Month)
5.Search for a command

Press enter to quit
"""

while True:
  answer =raw_input("What would you like to do ?")

  if answer=="":
    sys.exit()

  elif answer=="1":
    sortByVotes()

  elif answer=="2":
    print sortByVotesToday()

  elif answer=="3":
    print sortByVotesWeek()

  elif answer=="4":
    print sortByVotesMonth()
 
  elif answer=="5":
    print sortByMatch()

  else:
    print "Not a valid choice"



'Python' 카테고리의 다른 글

dateParse.py  (0) 2015.02.06
portScanner.py  (0) 2015.02.06
magin8Ball.py  (0) 2015.02.06
test_mysql.py  (0) 2015.02.06
weekNumber.py  (0) 2015.02.06
Posted by af334
2015. 2. 6. 22:24
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

import sys
import random

ans =True

while ans:
  question=raw_input("Ask the magic 8 ball a question : (press enter to quit) ")

  answers=random.randint(1,8)
 
  if question=="":
    sys.exit()
 
  elif answers==1:
    print "It is certain"

  elif answers==2:
    print "Outlook good"

  elif answers==3:
    print "You may rely on it"

  elif answers==4:
    print "Ask again later"

  elif answers==5:
    print "Concentrate and ask again"
 
  elif answers==6:
    print "Reply hazy, try again"

  elif answers==7:
    print "My reply is no"

  elif answers==8:
    print "My sources say no"



'Python' 카테고리의 다른 글

portScanner.py  (0) 2015.02.06
commandlineFu.py  (0) 2015.02.06
test_mysql.py  (0) 2015.02.06
weekNumber.py  (0) 2015.02.06
Some Libraries  (0) 2015.02.06
Posted by af334