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

import threading
import requests
import time
import urllib3
import json

urllib3.disable_warnings()

def getCrawl(url):
     session = requests.Session()
     session.trust_env = False
     session.verify = False
     receive = session.get(url)
     text = receive.text
     # text = text.encode('utf-8')
     mtext = json.dumps({"k": text})
     # print(json.loads(mtext)["k"])
     text = json.loads(mtext)["k"];
     time.sleep(1)
     print(text)
     get_data = json.dumps(text, indent=4)
     print(get_data)
target = "http://somesite.co.kr/uri1/uri2"
thread = threading.Thread(target=getCrawl, args=(target,))
thread.daemon = False
thread.start()

#print('Out of thread')

'Python' 카테고리의 다른 글

Getting snmp informations with python script  (0) 2020.04.22
USING THREAD IN PYTHON  (0) 2020.04.07
CRAWLING WITH PYTHON  (0) 2020.04.07
TRY TO CONNECT VIA SMB OR CIFS  (0) 2020.04.07
TRY TO CONNECT VIA MYSQL  (0) 2020.04.07
import sys
from pysnmp.hlapi import *
import csv


def walk(host, oid):
    for (errorIndication, errorStatus, errorIndex, varBinds) in nextCmd(SnmpEngine(), CommunityData('public'),
                                                                        UdpTransportTarget((host, 161), timeout=1,
                                                                                           retries=5), ContextData(),
                                                                        ObjectType(ObjectIdentity(oid)),
                                                                        lexicographicMode=True, lookupNames=True):
        if errorIndication:
            print(errorIndication, file=sys.stderr)
            break
        elif errorStatus:
            print('%s at %s' % (errorStatus.prettyPrint(), errorIndex and varBind[int(errorIndex) - 1][0] or '?'),
                  file=sys.stderr)
            break
        else:
            for varBind in varBinds:
                print(varBind)


def checkserver(ip):
    walk(ip, '1.3.6')


with open('snmplist.csv', newline='', encoding='utf-8') as csvfile:
    reader = csv.reader(csvfile, quoting=csv.QUOTE_ALL)
    for row in reader:
        try:
            print('IP : ' + row[0])
            checkserver(row[0])
        except:
            pass

'Python' 카테고리의 다른 글

Crawling Json type with Python thread  (0) 2020.04.26
USING THREAD IN PYTHON  (0) 2020.04.07
CRAWLING WITH PYTHON  (0) 2020.04.07
TRY TO CONNECT VIA SMB OR CIFS  (0) 2020.04.07
TRY TO CONNECT VIA MYSQL  (0) 2020.04.07
from smb.SMBConnection import SMBConnection

conn = SMBConnection(userid="", password="", client_machine_name="", servername="", 

                                domain="",use_ntlm_v2=True, is_direct_tcp=True)
conn.connect(serverip = "", 445)
shares = conn.listShares()

for share in shares:
      if not share.isSpecial and share.name not in ['NETLOGON', 'SYSVOL']:
            print("share name :" + share.name)
            sharedfiles = conn.listPath(share.name,'/')
            for sharedfile in sharedfiles:
                  print(sharedfile.filename)
                  conn.close()

'Python' 카테고리의 다른 글

Getting snmp informations with python script  (0) 2020.04.22
USING THREAD IN PYTHON  (0) 2020.04.07
CRAWLING WITH PYTHON  (0) 2020.04.07
TRY TO CONNECT VIA MYSQL  (0) 2020.04.07
TRY TO TEST FOR DEFAULT ACCOUNT VIA TELNET  (0) 2020.04.07
import pymysql

ratency = 2
conn = pymysql.connect(host="", user="", password="", read_timeout=ratency, write_timeout=ratency)

if conn.open == True:

     curs = conn.cursor()
     command = "show databases"
     curs.execute(command)
     rows = curs.fetchall()
     print(rows)
     conn.close()
     
''' case of using Dict type
cursor = conn.cursor(pymysql.cursors.DictCursor)
sql = 'select * from some_talbe'
cursor.execute(sql)
result = cursor.fetchall()
print(result)
'''
     
else:
      print("can not connected")

'Python' 카테고리의 다른 글

Getting snmp informations with python script  (0) 2020.04.22
USING THREAD IN PYTHON  (0) 2020.04.07
CRAWLING WITH PYTHON  (0) 2020.04.07
TRY TO CONNECT VIA SMB OR CIFS  (0) 2020.04.07
TRY TO TEST FOR DEFAULT ACCOUNT VIA TELNET  (0) 2020.04.07
import telnetlib

infile = open("list.txt", "r")
ips = []
delay_second = 2

account_tup = (("admin", "admin"),
               ("admin", "password"),
               ("root", "root"),
               ("root", "password"),
               ("root", ""),
               ("guest", ""),
               ("db2admin", "db2admin")
               ("db2inst1", "db2inst1")
               ("db2as", "db2as")
               ("db2fenc1", "db2fenc1")
               ("db2admin", "ibmdb2")
               ("db2inst1", "ibmdb2")
               ("db2as", "ibmdb2")
               ("db2fenc1", "ibmdb2")
              )

lines = infile.readlines()
for line in lines:
    ips.append(line)
infile.close()
total_count = (lines.__len__()) * (len(account_tup))
now_count = 1


def tryConnectTelnet(host, user, password):
    global now_count
    with telnetlib.Telnet(host) as con:
        con.read_until("Login:", delay_second)
        con.read_until(b"login:", delay_second)
        print("[Try Action] input account completed")
        con.write(user + b"\n")
        con.read_until("Password:", delay_second)
        print("[Try Action] input password completed")
        con.write(password + b"\n")
        now_count = now_count + 1
        if con.eof:
            return "Closed connection"
        # con.write(b"ls\n")
        # con.write(b"exit\n")
        # my_text = con.set_debuglevel(1000)
        return con.read_until(b".", delay_second)


def print_result(return_str):
    tag = b"[[[Return Result]]]"
    if len(return_str) <= 5:
        print((tag + b"enmpty").decode())
    else:
        print(len(return_str))
        print((tag + return_str).decode())


for ip in ips:
    host = ip.strip("\n")
    print("==========[" + ip + "]==========")
    for a_value in account_tup:
        print(r"====[" + str(now_count) + "/" + str(total_count) + " try to " + a_value[0] + "/" + a_value[1])
        return_value = tryConnectTelnet(host, a_value[0].encode(), a_value[1].encode())
        print_result(return_value)
        with open("output.txt", "a") as outfile:
            outfile.write(host + ":" + a_value[0] + ":" + a_value[1] + ":" +return_value.decode() + "\n")

'Python' 카테고리의 다른 글

Getting snmp informations with python script  (0) 2020.04.22
USING THREAD IN PYTHON  (0) 2020.04.07
CRAWLING WITH PYTHON  (0) 2020.04.07
TRY TO CONNECT VIA SMB OR CIFS  (0) 2020.04.07
TRY TO CONNECT VIA MYSQL  (0) 2020.04.07

+ Recent posts