Author Topic: Bomz new topic.  (Read 13052 times)

bomz

  • Member
  • **
  • Posts: 122
Re: Bomz new topic.
« Reply #30 on: August 13, 2021, 12:36:01 PM »
at least it's allow reduce filesize 512 b, when you need only 4 bytes for data, and reduce initialization time. political correctness is not my method. sad data must be placed before (under) it used and need one jmp

TouEnMasm

  • Member
  • *****
  • Posts: 1804
    • EditMasm
Re: Bomz new topic.
« Reply #31 on: August 13, 2021, 03:59:43 PM »
Quote
I don't say it not work at all. It not load "problem" sites not compatible with IE

IImportant result,I need to find for what .
Fa is a musical note to play with CL

TouEnMasm

  • Member
  • *****
  • Posts: 1804
    • EditMasm
Re: Bomz new topic.
« Reply #32 on: August 13, 2021, 06:04:00 PM »
I  am reviewing an old source code (not without problems) but i can now remember how it work.
The first step is to find the user agent for your browser and your system.
When you have it,this can need a little search,put it in the dialog box.
After there is to deal with the commands send to to the search engine ,the search? is one of them.
A full grammar of those command can be found in internet pages.

For your own user agent try this page:
http://www.infowebmaster.fr/outils/mon-user-agent.php
Fa is a musical note to play with CL

bomz

  • Member
  • **
  • Posts: 122
Re: Bomz new topic.
« Reply #33 on: August 13, 2021, 08:29:02 PM »
sites coluded with Bill Gates and not support IE use another method not checking user-agent
Mozilla have own certificates and curl use mozilla sertificates so I first think about it
if make console utilites using winsockets it would crashes as curl

http://booomz.000webhostapp.com/pictures/Project005.gif

TimoVJL

  • Member
  • *****
  • Posts: 1101
Re: Bomz new topic.
« Reply #34 on: August 13, 2021, 08:49:15 PM »
This code won't work with www.livenewsnow.com
Code: [Select]
hSession = WinHttpOpen(L"Mozilla/5.0 (Windows NT 6.1; Win64; x64)", WINHTTP_ACCESS_TYPE_NO_PROXY, WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0);
hConnect = WinHttpConnect(hSession, L"www.livenewsnow.com", INTERNET_DEFAULT_HTTPS_PORT, 0);
hRequest = WinHttpOpenRequest(hConnect, NULL, L"/", NULL, WINHTTP_NO_REFERER, WINHTTP_DEFAULT_ACCEPT_TYPES, WINHTTP_FLAG_SECURE | WINHTTP_FLAG_BYPASS_PROXY_CACHE | WINHTTP_FLAG_ESCAPE_DISABLE);
WinInet/WinHttp supports TLS 1.2 and site too.
May the source be with you

bomz

  • Member
  • **
  • Posts: 122
Re: Bomz new topic.
« Reply #35 on: August 13, 2021, 09:37:54 PM »
This code won't work with www.livenewsnow.com
Code: [Select]
hSession = WinHttpOpen(L"Mozilla/5.0 (Windows NT 6.1; Win64; x64)", WINHTTP_ACCESS_TYPE_NO_PROXY, WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0);
hConnect = WinHttpConnect(hSession, L"www.livenewsnow.com", INTERNET_DEFAULT_HTTPS_PORT, 0);
hRequest = WinHttpOpenRequest(hConnect, NULL, L"/", NULL, WINHTTP_NO_REFERER, WINHTTP_DEFAULT_ACCEPT_TYPES, WINHTTP_FLAG_SECURE | WINHTTP_FLAG_BYPASS_PROXY_CACHE | WINHTTP_FLAG_ESCAPE_DISABLE);
WinInet/WinHttp supports TLS 1.2 and site too.
do you have winhttp lib and inc for masm?

Code: [Select]
WinHttpOpen    PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD
WinHttpConnect   PROTO :DWORD,:DWORD,:DWORD,:DWORD
WinHttpCloseHandle   PROTO :DWORD
WinHttpOpenRequest PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD

WINHTTP_ACCESS_TYPE_DEFAULT_PROXY       equ         0
WINHTTP_ACCESS_TYPE_NO_PROXY           equ         1
WINHTTP_ACCESS_TYPE_NAMED_PROXY        equ         3
WINHTTP_NO_PROXY_NAME     equ   NULL
WINHTTP_NO_PROXY_BYPASS      equ   NULL

can't find LIB, selfmade not work

WinHTTP NEED wide-character strings

TimoVJL

  • Member
  • *****
  • Posts: 1101
Re: Bomz new topic.
« Reply #36 on: August 13, 2021, 10:14:40 PM »
From Pelles C
May the source be with you

bomz

  • Member
  • **
  • Posts: 122
Re: Bomz new topic.
« Reply #37 on: August 13, 2021, 10:24:48 PM »
From Pelles C


Quote
Microsoft (R) Macro Assembler Version 10.00.40219.01
Copyright (C) Microsoft Corporation.  All rights reserved.

 Assembling: C:\Users\bomzzz\Desktop\request\cdownload.asm

***********
ASCII build
***********

C:\Users\bomzzz\Desktop\request\winhttp.lib(1) : error A2008:syntax error : !
C:\Users\bomzzz\Desktop\request\winhttp.lib(2) : error A2044:invalid character in file
C:\Users\bomzzz\Desktop\request\winhttp.lib(3) : error A2044:invalid character in file
C:\Users\bomzzz\Desktop\request\winhttp.lib(4) : error A2044:invalid character in file
C:\Users\bomzzz\Desktop\request\winhttp.lib(5) : error A2044:invalid character in file
C:\Users\bomzzz\Desktop\request\winhttp.lib(6) : error A2044:invalid character in file
C:\Users\bomzzz\Desktop\request\winhttp.lib(7) : error A2044:invalid character in file
C:\Users\bomzzz\Desktop\request\winhttp.lib(7) : fatal error A1009:line too long

Microsoft (R) Incremental Linker Version 10.00.40219.01
Copyright (C) Microsoft Corporation.  All rights reserved.

LINK : fatal error LNK1181: cannot open input file 'cdownload.obj'

bomz

  • Member
  • **
  • Posts: 122
Re: Bomz new topic.
« Reply #38 on: August 14, 2021, 01:32:03 PM »
https://github.com/Tencent/mars/blob/master/mars/comm/windows/win32/winhttp.h

Quote
12175 WinHTTPSendRequest A security error occurred. This means your Windows operating system has not been configured for TLS 1.2. ... To configure your Windows operating system's WinHTTP stack for TLS 1.2, run Windows Update and make sure all updates have been installed.

the same result with HTTPAnalyzer working without not

WinHttpQueryDataAvailable
Quote
ERROR_WINHTTP_INCORRECT_HANDLE_STATE 12019
The requested operation cannot be carried out because the handle supplied is not in the correct state.

Code: [Select]
__WIN7__ equ 1
.386

.model flat, stdcall
option casemap :none

include \MASM32\include\windows.inc
include \MASM32\include\user32.inc
include \MASM32\include\kernel32.inc
include \MASM32\include\wininet.inc

;include winhttp.lib

WINHTTP_ACCESS_TYPE_DEFAULT_PROXY equ NULL
WINHTTP_ACCESS_TYPE_NO_PROXY equ 1
WINHTTP_ACCESS_TYPE_NAMED_PROXY equ 3
WINHTTP_NO_PROXY_NAME equ NULL
WINHTTP_NO_PROXY_BYPASS equ NULL
WINHTTP_NO_REFERER equ NULL
WINHTTP_DEFAULT_ACCEPT_TYPES equ NULL

WINHTTP_FLAG_ASYNC equ 10000000h ;this session is asynchronous (where supported)
WINHTTP_FLAG_SECURE equ 800000h ;use SSL if applicable (HTTPS)
WINHTTP_FLAG_ESCAPE_PERCENT equ 4h ;if escaping enabled, escape percent as well
WINHTTP_FLAG_NULL_CODEPAGE equ 8h ;assume all symbols are ASCII, use fast convertion
WINHTTP_FLAG_BYPASS_PROXY_CACHE equ 100h ;add "pragma: no-cache" request header
WINHTTP_FLAG_REFRESH equ 100h
WINHTTP_FLAG_BYPASS_PROXY_CACHE equ 100h
WINHTTP_FLAG_ESCAPE_DISABLE equ 40h ;disable escaping
WINHTTP_FLAG_ESCAPE_DISABLE_QUERY equ 80h ;if escaping enabled escape path part, but do not escape query



.data
;UserAgent db "Mozilla/5.0 (Windows NT 6.1; Win64; x64)",0
UserAgent dw "M","o","z","i","l","l","a","/","5",".","0"," ","(","W","i","n","d","o","w","s"," ","N","T"," ","6"
dw ".","1",";"," ","W","i","n","6","4",";"," ","x","6","4",")", 0 ;
dw 80 ;
dw 82 ;
dd offset UserAgent ;

;Server db "www.livenewsnow.com",0;
Server dw "w","w","w",".","l","i","v","e","n","e","w","s","n","o","w",".","c","o","m", 0 ;
dw 38 ;
dw 40 ;
dd offset Server ;

;FName db "/",0
FName dw "/", 0 ;
dw 2 ;
dw 4 ;
dd offset FName ;

WinHttpOpen db "WinHttpOpen",0
WinHttpConnect db "WinHttpConnect",0
WinHttpOpenRequest db "WinHttpOpenRequest",0
WinHttpSendRequest db "WinHttpSendRequest",0
WinHttpQueryDataAvailable db "WinHttpQueryDataAvailable",0
WinHttpCloseHandle db "WinHttpCloseHandle",0
WinHttpReadData db "WinHttpReadData",0
LibName db "winhttp.dll",0

form db "EAX: %u", 0

.data?
Buffer db 65536 dup(?);4096
hSession dd ?
hRequest dd ?
hConnect dd ?
hOutCon dd ?
_rb dd ?
_wb dd ?
_fs dd ?
hMemory HANDLE ?
hMemPointer dd ?
hWinHTTP dd ?
hCloseHandle dd ?
hData dd ?
hRead dd ?
.code
start:

invoke LoadLibrary, addr LibName
mov hWinHTTP, eax
invoke GetProcAddress, hWinHTTP, addr WinHttpCloseHandle
mov hCloseHandle, eax
invoke GetProcAddress, hWinHTTP, addr WinHttpOpen
push 0
push WINHTTP_NO_PROXY_BYPASS
push WINHTTP_NO_PROXY_NAME
push WINHTTP_ACCESS_TYPE_NO_PROXY
push offset UserAgent
call eax
.if eax==0
invoke GetLastError
mov ebx,eax
;invoke wsprintf,addr Buffer,addr form,eax
;invoke MessageBox,0,addr Buffer,NULL,MB_ICONASTERISK
jmp NoParam
.endif
mov hSession,eax

invoke GetProcAddress, hWinHTTP, addr WinHttpConnect
push 0
push INTERNET_DEFAULT_HTTPS_PORT
push offset Server
push hSession
call eax
.if eax==0
invoke GetLastError
mov ebx,eax
;invoke wsprintf,addr Buffer,addr form,eax
;invoke MessageBox,0,addr Buffer,NULL,MB_ICONASTERISK
jmp @3
.endif
mov hConnect,eax

invoke GetProcAddress, hWinHTTP, addr WinHttpOpenRequest
push WINHTTP_FLAG_SECURE OR WINHTTP_FLAG_BYPASS_PROXY_CACHE OR WINHTTP_FLAG_ESCAPE_DISABLE
push WINHTTP_DEFAULT_ACCEPT_TYPES
push WINHTTP_NO_REFERER
push 0
push offset FName
push 0
push hConnect
call eax
.if eax==0
invoke GetLastError
mov ebx,eax
;invoke wsprintf,addr Buffer,addr form,eax
;invoke MessageBox,0,addr Buffer,NULL,MB_ICONASTERISK
jmp @2
.endif
mov hRequest,eax

invoke GetProcAddress, hWinHTTP, addr WinHttpSendRequest
push 0
push 0
push 0
push 0
push 0
push 0
push hRequest
call eax
.if eax==0
invoke GetLastError
mov ebx,eax
invoke wsprintf,addr Buffer,addr form,eax
invoke MessageBox,0,addr Buffer,NULL,MB_ICONASTERISK
jmp @1
.endif

invoke GetProcAddress, hWinHTTP, addr WinHttpQueryDataAvailable
mov hData, eax
invoke GetProcAddress, hWinHTTP, addr WinHttpReadData
mov hRead, eax
invoke GetStdHandle, STD_OUTPUT_HANDLE
mov hOutCon,eax
xor ebx,ebx
@@:
push offset _rb
push hRequest
call hData
.if !eax
invoke GetLastError
mov ebx,eax
invoke wsprintf,addr Buffer,addr form,eax
invoke MessageBox,0,addr Buffer,NULL,MB_ICONASTERISK
jmp @1
.endif
cmp _rb, 0
je @1

push offset _rb
push _rb
push offset Buffer
push hRequest
call hRead
.if !eax
invoke GetLastError
mov ebx,eax
jmp @1
.endif
invoke WriteFile,hOutCon,addr Buffer,_rb,addr _wb,NULL
jmp @B

@1:
push hRequest
call hCloseHandle
@2:
push hConnect
call hCloseHandle
@3:
push hSession
call hCloseHandle
NoParam:
invoke FreeLibrary, hWinHTTP
invoke ExitProcess,ebx
end start

Update to enable TLS 1.1 and TLS 1.2 as default secure protocols in WinHTTP in Windows
« Last Edit: August 14, 2021, 03:51:29 PM by bomz »

TimoVJL

  • Member
  • *****
  • Posts: 1101
Re: Bomz new topic.
« Reply #39 on: August 14, 2021, 04:06:49 PM »
May the source be with you

bomz

  • Member
  • **
  • Posts: 122
Re: Bomz new topic.
« Reply #40 on: August 14, 2021, 07:08:29 PM »
this add problems. after update I lost windows activation, windows boot and add windows end support
WinHttpQueryDataAvailable 12019


bomz

  • Member
  • **
  • Posts: 122
Re: Bomz new topic.
« Reply #41 on: August 14, 2021, 08:51:42 PM »
12019 problem decided. working code


Quote
12175
One or more errors were found in the Secure Sockets Layer (SSL) certificate sent by the server. To determine what type of error was encountered, check for a WINHTTP_CALLBACK_STATUS_SECURE_FAILURE notification in a status callback function. For more information, see WINHTTP_STATUS_CALLBACK.

change security flags don't help
How do you use WinHTTP to do SSL with a self signed cert
twitter.com 12175
google.com OK

Authentication in WinHTTP
« Last Edit: August 15, 2021, 01:00:59 AM by bomz »

TouEnMasm

  • Member
  • *****
  • Posts: 1804
    • EditMasm
Re: Bomz new topic.
« Reply #42 on: August 15, 2021, 04:34:11 AM »

It seems that you have forgotten to get the unicode function terminate by a W
Ansi function  are terminate by A
Fa is a musical note to play with CL

bomz

  • Member
  • **
  • Posts: 122
Re: Bomz new topic.
« Reply #43 on: August 15, 2021, 04:38:14 AM »
winhttp support only unicode
winhttp.lib need coff to omf convertion

Code: [Select]
; ------------------------------------------
 ; prototypes for EXPORT winhttp functions
 ; ------------------------------------------

c_winhttp typedef PROTO C :VARARG

externdef _imp__DllCanUnloadNow:PTR c_winhttp
crt_DllCanUnloadNow equ <_imp__DllCanUnloadNow>

externdef _imp__DllGetClassObject:PTR c_winhttp
crt_DllGetClassObject equ <_imp__DllGetClassObject>

externdef _imp__Private1:PTR c_winhttp
crt_Private1 equ <_imp__Private1>

externdef _imp__SvchostPushServiceGlobals:PTR c_winhttp
crt_SvchostPushServiceGlobals equ <_imp__SvchostPushServiceGlobals>

externdef _imp__WinHttpAddRequestHeaders:PTR c_winhttp
crt_WinHttpAddRequestHeaders equ <_imp__WinHttpAddRequestHeaders>

externdef _imp__WinHttpAutoProxySvcMain:PTR c_winhttp
crt_WinHttpAutoProxySvcMain equ <_imp__WinHttpAutoProxySvcMain>

externdef _imp__WinHttpCheckPlatform:PTR c_winhttp
crt_WinHttpCheckPlatform equ <_imp__WinHttpCheckPlatform>

externdef _imp__WinHttpCloseHandle:PTR c_winhttp
crt_WinHttpCloseHandle equ <_imp__WinHttpCloseHandle>

externdef _imp__WinHttpConnect:PTR c_winhttp
crt_WinHttpConnect equ <_imp__WinHttpConnect>

externdef _imp__WinHttpCrackUrl:PTR c_winhttp
crt_WinHttpCrackUrl equ <_imp__WinHttpCrackUrl>

externdef _imp__WinHttpCreateUrl:PTR c_winhttp
crt_WinHttpCreateUrl equ <_imp__WinHttpCreateUrl>

externdef _imp__WinHttpDetectAutoProxyConfigUrl:PTR c_winhttp
crt_WinHttpDetectAutoProxyConfigUrl equ <_imp__WinHttpDetectAutoProxyConfigUrl>

externdef _imp__WinHttpGetDefaultProxyConfiguration:PTR c_winhttp
crt_WinHttpGetDefaultProxyConfiguration equ <_imp__WinHttpGetDefaultProxyConfiguration>

externdef _imp__WinHttpGetIEProxyConfigForCurrentUser:PTR c_winhttp
crt_WinHttpGetIEProxyConfigForCurrentUser equ <_imp__WinHttpGetIEProxyConfigForCurrentUser>

externdef _imp__WinHttpGetProxyForUrl:PTR c_winhttp
crt_WinHttpGetProxyForUrl equ <_imp__WinHttpGetProxyForUrl>

externdef _imp__WinHttpOpen:PTR c_winhttp
crt_WinHttpOpen equ <_imp__WinHttpOpen>

externdef _imp__WinHttpOpenRequest:PTR c_winhttp
crt_WinHttpOpenRequest equ <_imp__WinHttpOpenRequest>

externdef _imp__WinHttpQueryAuthSchemes:PTR c_winhttp
crt_WinHttpQueryAuthSchemes equ <_imp__WinHttpQueryAuthSchemes>

externdef _imp__WinHttpQueryDataAvailable:PTR c_winhttp
crt_WinHttpQueryDataAvailable equ <_imp__WinHttpQueryDataAvailable>

externdef _imp__WinHttpQueryHeaders:PTR c_winhttp
crt_WinHttpQueryHeaders equ <_imp__WinHttpQueryHeaders>

externdef _imp__WinHttpQueryOption:PTR c_winhttp
crt_WinHttpQueryOption equ <_imp__WinHttpQueryOption>

externdef _imp__WinHttpReadData:PTR c_winhttp
crt_WinHttpReadData equ <_imp__WinHttpReadData>

externdef _imp__WinHttpReceiveResponse:PTR c_winhttp
crt_WinHttpReceiveResponse equ <_imp__WinHttpReceiveResponse>

externdef _imp__WinHttpSendRequest:PTR c_winhttp
crt_WinHttpSendRequest equ <_imp__WinHttpSendRequest>

externdef _imp__WinHttpSetCredentials:PTR c_winhttp
crt_WinHttpSetCredentials equ <_imp__WinHttpSetCredentials>

externdef _imp__WinHttpSetDefaultProxyConfiguration:PTR c_winhttp
crt_WinHttpSetDefaultProxyConfiguration equ <_imp__WinHttpSetDefaultProxyConfiguration>

externdef _imp__WinHttpSetOption:PTR c_winhttp
crt_WinHttpSetOption equ <_imp__WinHttpSetOption>

externdef _imp__WinHttpSetStatusCallback:PTR c_winhttp
crt_WinHttpSetStatusCallback equ <_imp__WinHttpSetStatusCallback>

externdef _imp__WinHttpSetTimeouts:PTR c_winhttp
crt_WinHttpSetTimeouts equ <_imp__WinHttpSetTimeouts>

externdef _imp__WinHttpTimeFromSystemTime:PTR c_winhttp
crt_WinHttpTimeFromSystemTime equ <_imp__WinHttpTimeFromSystemTime>

externdef _imp__WinHttpTimeToSystemTime:PTR c_winhttp
crt_WinHttpTimeToSystemTime equ <_imp__WinHttpTimeToSystemTime>

externdef _imp__WinHttpWriteData:PTR c_winhttp
crt_WinHttpWriteData equ <_imp__WinHttpWriteData>

TouEnMasm

  • Member
  • *****
  • Posts: 1804
    • EditMasm
Re: Bomz new topic.
« Reply #44 on: August 15, 2021, 05:31:43 AM »

seem to work on windows 10,see reussite.txt
Little modifies on the source
Fa is a musical note to play with CL