Esempio n. 1
0
 def reloadServer(self):
     httpServ = httplib.HTTPConnection("localhost", 9090)
     httpServ.connect()
     httpServ.request("POST", "/-/reload")
     response = httpServ.getresponse()
     #print (response.status)
     httpServ.close()
Esempio n. 2
0
    def onOffMultiple(self, channels, on=0):
        if on:
            on_label = "ON"
        else:
            on_label = "OFF"

        for channel in channels:
            conn = httplib2.HTTPConnection('powerswitches.zhinst.com')
            conn.request(
                "GET", "/index.php?ajax=set&sid=%d&chid=%d&val=%d&su=%d" %
                (self.sid, channel, on, self.su))
            response = conn.getresponse()
            if not (response.status == 200):
                logger.error(
                    "HTTP Error %s(%d) during switching %s channel %d %s%s." %
                    (response.reason, response.status, self.host, channel,
                     on_label, self.su_label))
            else:
                resp_body = response.read()
                m = re.match('^ERR:(.*)$', resp_body)
                if m:
                    logger.error(
                        "Server responded with '%s' while switching %s channel %d %s%s."
                        % (m.group(1), self.host, channel, on_label,
                           self.su_label))
Esempio n. 3
0
def checkIP(ip):
    checkUrl = ip + ":80"
    getContent = ""
    httplib2.socket.setdefaulttimeout(5)
    conn = httplib2.HTTPConnection(checkUrl)

    try:
        conn.request("GET", "/", headers={"Host": appDomain})
        r = conn.getresponse()
        getContent = r.read(15)
    finally:
        if getContent == "<!doctype html>":
            print(ip + "[ok]")
        else:
            print(ip + "[error]")
Esempio n. 4
0
def checkip(ip):
    checkurl = ip + ":80"
    getcontent = ""
    httplib2.socket.setdefaulttimeout(5)  #定义http连接超时时间(5秒)
    conn = httplib2.HTTPConnection(checkurl)  #创建http连接对象

    try:
        conn.request("GET", "/", headers={"Host":
                                          appdomain})  #发起URL请求,添加host主机头
        r = conn.getresponse()
        getcontent = r.read(15)  #获取URL页面前15个字符,以便做可用性校验
    finally:
        if getcontent == "<!doctype html>":  #监控URL页的内容一般是事先定义好,比如“HTTP200”等
            print(ip + " [OK]")
        else:
            print(ip + " [Error]")  #此处可放告警程序,可以是邮件、短信通知
Esempio n. 5
0
def addtoplaylist(file):
    global uuid
    # feel free to suggest more
    movieExtensions = ['.mp3', '.m4v', '.mkv', '.mp4', '.mpg', '.mpeg', '.avi']
    if not os.path.splitext(file)[1] in movieExtensions:
        return
    conn = httplib.HTTPConnection('127.0.0.1', 8080)
    conn.request('POST', '/playlist', file)
    resp = conn.getresponse()
    if not uuid:
        if resp.status == 200:
            try:
                data = resp.read()
                uuid = json.loads(data)['uuid']
            except:
                pass
    conn.close()
Esempio n. 6
0
def send_sms(text, mobile):
    params = urllib.urlencode({
        'account': account,
        'password': password,
        'content': text,
        'mobile': mobile,
        'format': 'json'
    })
    headers = {
        "Content-type": "application/x-www-form-urlencoded",
        "Accept": "text/plain"
    }
    conn = httplib2.HTTPConnection(host, port=80, timeout=30)
    conn.request("POST", sms_send_uri, params, headers)
    response = conn.getresponse()
    response_str = response.read()
    conn.close()
    return response_str
Esempio n. 7
0
def image_exists(domain, path, check_size=False, size_limit=1024):
    try:
        conn = httplib2.HTTPConnection(domain)
        conn.request('HEAD', path)
        response = conn.getresponse()
        headers = response.getheaders()
        conn.close()
    except:
        return False

    try:
        length = int([x[1] for x in headers if x[0] == 'content-length'][0])
    except:
        length = 0
    if length > MAX_SIZE:
        return False

    return response.status == 200
Esempio n. 8
0
    def internet(self, log=True):
        try:
            import httplib2 as _httplib

            conn = _httplib.HTTPConnectionWithTimeout(
                self.target_host, timeout=self.timeout
            )
        except ImportError:
            import http.client as _httplib

            conn = _httplib.HTTPConnection(self.target_host, timeout=self.timeout)
        try:
            conn.request("HEAD", "/")
            conn.close()
            self.is_internet = True

        except:
            self.is_internet = False
        if log:
            logxs.printf("Internet status : " + str(self.is_internet), _int=True)
import httplib2

httpclient = None
r = httplib2.HTTPConnection('www.xxx.org', 80)
httpclient.request('GET', '/CloudBean/capture.php?name=liu&pass=wew')
res = httpclient.getresponse()
print res.status
print res.reason
print res.read()
Esempio n. 10
0
 def __init__(self, host, port, username, password):
     authpair = "%s:%s" % (username, password)
     self.authhdr = "Basic %s" % (base64.b64encode(authpair))
     self.conn = httplib.HTTPConnection(host, port, False, 30)
Esempio n. 11
0
                uuid = json.loads(data)['uuid']
            except:
                pass
    conn.close()


def tree(path):
    for f in os.listdir(path):
        f = os.path.join(path, f)
        if os.path.isfile(f):
            addtoplaylist(f)
        if os.path.isdir(f):
            tree(f)


if __name__ == '__main__':
    # don't autostart when folders are queued
    playFile = False
    for f in sys.argv[1:]:
        f = os.path.realpath(f)
        if os.path.isfile(f):
            addtoplaylist(f)
            playFile = True
        if os.path.isdir(f):
            tree(f)
    if uuid and playFile and not queue_only:
        conn = httplib.HTTPConnection('127.0.0.1', 8080)
        conn.request('GET', '/play/' + uuid)
        conn.getresponse()
        conn.close()
Esempio n. 12
0
        'panel-administracion/login.brf', 'wp-login.brf', 'adminLogin.brf',
        'admin/adminLogin.brf', 'home.brf', 'admin.brf', 'adminarea/index.brf',
        'adminarea/admin.brf', 'adminarea/login.brf',
        'panel-administracion/index.brf', 'panel-administracion/admin.brf',
        'modelsearch/index.brf', 'modelsearch/admin.brf',
        'admincontrol/login.brf', 'adm/admloginuser.brf', 'admloginuser.brf',
        'admin2.brf', 'admin2/login.brf', 'admin2/index.brf',
        'usuarios/login.brf', 'adm/index.brf', 'adm.brf', 'affiliate.brf',
        'adm_auth.brf', 'memberadmin.brf', 'administratorlogin.brf'
    ]

    try:
        site = raw_input("Web Site for Scan?: ")
        site = site.replace("http://", "")
        print("\tChecking website " + site + "...")
        conn = httplib2.HTTPConnection(site)
        conn.connect()
        print("\t[$] Yes... Server is Online.")
    except (httplib2.Response, socket.error) as Exit:
        raw_input("\t [!] Oops Error occured, Server offline or invalid URL")
        exit()
    print("Enter site source code:")
    print("1 PHP")
    print("2 ASP")
    print("3 CFM")
    print("4 JS")
    print("5 CGI")
    print("6 BRF")
    print("\nPress 1 and 'Enter key' for Select PHP\n")
    code = input("> ")