Exemple #1
0
    def InternetOpenUrl(self, emu, argv, ctx={}):
        """
        void InternetOpenUrlA(
            HINTERNET hInternet,
            LPCSTR    lpszUrl,
            LPCSTR    lpszHeaders,
            DWORD     dwHeadersLength,
            DWORD     dwFlags,
            DWORD_PTR dwContext
        );
        """
        hInternet, lpszUrl, lpszHeaders, dwHeadersLength, dwFlags, dwContext = argv
        cw = self.get_char_width(ctx)
        headers = ""
        if lpszUrl:
            url = self.read_mem_string(lpszUrl, cw)
            argv[1] = url
        if lpszHeaders:
            headers = self.read_mem_string(lpszHeaders, cw)
            argv[2] = headers

        defs = windefs.get_flag_defines(dwFlags)
        argv[4] = " | ".join(defs)

        wini = self.netman.get_wininet_object(hInternet)
        if not wini:
            return 0
        crack = urlparse(url)
        if crack.scheme == "http":
            # FIXME : parse port in url netloc
            port = 80
        else:
            port = 443
        sess = wini.new_session(crack.netloc, port, "", "", "", defs,
                                dwContext)
        if not sess:
            return 0
        req = sess.new_request("GET", url, None, None, None, defs, dwContext)
        req_str = req.format_http_request(headers=headers)
        self.log_network(
            req.get_server() + req.objname.path,
            port,
            headers=req_str,
            proto="https" if port == 443 else "http",
            method=req.verb.upper(),
        )
        return req.get_handle()
Exemple #2
0
    def InternetOpenUrl(self, emu, argv, ctx={}):
        """
        void InternetOpenUrlA(
            HINTERNET hInternet,
            LPCSTR    lpszUrl,
            LPCSTR    lpszHeaders,
            DWORD     dwHeadersLength,
            DWORD     dwFlags,
            DWORD_PTR dwContext
        );
        """
        hInternet, lpszUrl, lpszHeaders, dwHeadersLength, dwFlags, dwContext = argv
        cw = self.get_char_width(ctx)
        if lpszUrl:
            url = self.read_mem_string(lpszUrl, cw)
            argv[1] = url
        if lpszHeaders:
            headers = self.read_mem_string(lpszHeaders, cw)
            argv[2] = headers

        defs = windefs.get_flag_defines(dwFlags)
        argv[4] = ' | '.join(defs)

        wini = self.netman.get_wininet_object(hInternet)
        if not wini:
            return 0
        crack = urlparse(url)
        if crack.scheme == "http":
            # FIXME : parse port in url netloc
            port = 80
        else:
            port = 443
        self.log_http(crack.netloc, port, headers=lpszHeaders)
        sess = wini.new_session(crack.netloc, port, '', '', '', defs,
                                dwContext)
        if not sess:
            return 0
        req = sess.new_request("GET", url, None, None, None, defs, dwContext)
        return req.get_handle()
Exemple #3
0
    def WinHttpOpenRequest(self, emu, argv, ctx={}):
        """
        WINHTTPAPI HINTERNET WinHttpOpenRequest(
          IN HINTERNET hConnect,
          IN LPCWSTR   pwszVerb,
          IN LPCWSTR   pwszObjectName,
          IN LPCWSTR   pwszVersion,
          IN LPCWSTR   pwszReferrer,
          IN LPCWSTR   *ppwszAcceptTypes,
          IN DWORD     dwFlags
        );
        """
        hnd, verb, objname, ver, ref, accepts, flags = argv

        if verb:
            verb = self.read_mem_string(verb, 2)
            argv[1] = verb
        if objname:
            objname = self.read_mem_string(objname, 2)
            argv[2] = objname
        if ver:
            ver = self.read_mem_string(ver, 2)
            argv[3] = ver
        if ref:
            ref = self.read_mem_string(ref, 2)
            argv[4] = ref
        if accepts:
            accepts = self.read_mem_string(accepts, 2)
            argv[5] = accepts

        defs = windefs.get_flag_defines(flags)
        argv[6] = " | ".join(defs)

        sess = self.netman.get_wininet_object(hnd)
        req = sess.new_request(verb, objname, ver, ref, accepts, defs, None)
        hdl = req.get_handle()

        return hdl
Exemple #4
0
    def HttpOpenRequest(self, emu, argv, ctx={}):
        """
        void HttpOpenRequest(
          HINTERNET hConnect,
          LPTSTR    lpszVerb,
          LPTSTR    lpszObjectName,
          LPTSTR    lpszVersion,
          LPTSTR    lpszReferrer,
          LPTSTR    *lplpszAcceptTypes,
          DWORD     dwFlags,
          DWORD_PTR dwContext
        );
        """
        hnd, verb, objname, ver, ref, accepts, flags, dwctx = argv

        cw = self.get_char_width(ctx)
        if verb:
            verb = self.read_mem_string(verb, cw)
            argv[1] = verb
        if objname:
            objname = self.read_mem_string(objname, cw)
            argv[2] = objname
        if ver:
            ver = self.read_mem_string(ver, cw)
            argv[3] = ver
        if ref:
            ref = self.read_mem_string(ref, cw)
            argv[4] = ref

        defs = windefs.get_flag_defines(flags)
        argv[6] = ' | '.join(defs)

        sess = self.netman.get_wininet_object(hnd)
        req = sess.new_request(verb, objname, ver, ref, accepts, defs, dwctx)
        hdl = req.get_handle()
        return hdl