PDA

View Full Version : ProSocks



Brandon
04-20-2014, 01:53 PM
ProSocks Library

I finally got frustrated enough waiting on the Simba developers to get Simba's sockets together.. So.. I wrote a plugin that should have some neat functionality and is 100% portable. It is statically compiled so no extra downloads required. I know Simba is open source and I can add the code to it myself.. Just thought a plugin would handle it better and it would be easy for anyone to use it without having to re-install or re-download Simba.


Features:
SSL & TLS enabled.
Read/Write/Accepts, GET, POST, etc.
Email (SMTP), POP3, etc.



Future Features (maybe):
Lape style structures.


Download:
https://github.com/Brandon-T/ProSocks/releases


If using ASM (ProSocks v.01):


format PE console
entry main

include 'Code/FASM/include/macro/import32.inc' ;Includes

section '.idata' import data readable
;Imports
library msvcrt,'msvcrt.dll', prosocks,'prosocks.dll'
import msvcrt, printf, 'printf',\
exit,'exit', getchar, 'getchar', scanf, 'scanf',\
sprintf, 'sprintf', malloc, 'malloc', free, 'free'

import prosocks, CreateSocket, 'CreateSocket', ConnectSocket, 'ConnectSocket',\
CloseSocket, 'CloseSocket', FreeSocket, 'FreeSocket', AcceptSocket, 'AcceptSocket',\
ReadSocket, 'ReadSocket', WriteSocket, 'WriteSocket'



section '.data' data readable writeable
;Formatters
StringFormat db "%s", 13, 10, 0
StringExFormat db "%.*s", 13, 10, 0
ByteFormat db "%x", 13, 10, 0
AddressFormat db "%p", 13, 10, 0
NumberFormat db "%d", 13, 10, 0
ErrorFormat db "Error %s", 13, 10, 0

;Strings

CannotCreateSocket db "Cannot create socket.", 0
CannotConnectSocket db "Cannot connect socket.", 0
Host db "raw.githubusercontent.com", 0
RequestedFile db "Brandon-T/ProSocks/master/README.md", 0

;Formatted Strings

GetHeader db "GET /%s HTTP/1.1", 13, 10,\
"Host: %s", 13, 10,\
"Connection: close", 13, 10,\
"User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11", 13, 10,\
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", 13, 10,\
"Accept-Language: en-US,en;q=0.8", 13, 10,\
"Accept-Charset: ISO-8859-1,UTF-8;q=0.7,*;q=0.7", 13, 10,\
"Cache-Control: no-cache", 13, 10, 13, 10, 0


struc sizeof [args]
{
common .args
sizeof.#. = $-.
}

struc SockInfo sock, ssl, ctx, address, type, timeout, port, connected, blockmode
{
.sock dd sock
.ssl dd ssl
.ctx dd ctx
.address dd address
.type dd type
.timeout dd timeout
.port dw port;
.connected db connected
.blockmode db blockmode
}

sizeof.SockInfo = 28
sockinfo SockInfo 0, 0, 0, 0, 0, 0, 0, 0, 0
buffer db 512 dup(0)
buffptr rd 0

section '.code' code readable executable
main:
push ebp
mov ebp,esp

mov [sockinfo.address], Host ;set address
mov [sockinfo.timeout], 0x9C4 ;set timeout - 2500ms
mov [sockinfo.port], 0x1BB ;set port - 463
mov [sockinfo.blockmode], 0x1 ;set blocking

push sockinfo
call [CreateSocket] ;Create a socket. bool __cdecl CreateSocket(SSLSocket* ssl_info);
add esp, 0x04

push eax
push CannotCreateSocket
call PrintError ;If there were any errors, print them and quit.
cmp eax, 0x00
je .quit


push sockinfo
call [ConnectSocket] ;Connect the socket. bool __cdecl ConnectSocket(SSLSocket* ssl_info);
add esp, 0x04

push eax
push CannotConnectSocket
call PrintError ;If there were any errors, print them and quit.
cmp eax, 0x00
je .quit


push Host
push RequestedFile
push GetHeader
push buffer
call [sprintf] ;Create the get header.
add esp, 0x10


push eax
push buffer
push sockinfo
call [WriteSocket]
add esp, 0x0C
;sub esp, 0x204
;mov dword[ebp + 0x04], esp

push Host
push RequestedFile
push GetHeader
push buffer ;push dword[ebp + 0x04]
call [sprintf]
add esp, 0x10


push eax
push buffer
push sockinfo
call [WriteSocket] ;Write the buffer to the socket.

push 0x4E20
push buffptr
call SafePtrAlloc ;Allocate a buffer for reading.

push 0x4E20
push dword
push sockinfo
call [ReadSocket] ;Read the headers into the buffer.
add esp, 0x0C


push dword[buffptr]
push StringFormat
call [printf] ;Print the buffer/headers
add esp, 0x08

push 0xD0
push dword[buffptr]
push sockinfo
call [ReadSocket] ;Read the response into the buffer
add esp, 0x0C

push dword[buffptr]
push eax
push StringExFormat
call [printf] ;Print the buffer/data
add esp, 0x0C


push buffptr
call SafePtrFree ;Free the allocated buffer.


.quit:
push sockinfo
call [FreeSocket]
add esp, 0x04


call [getchar]
mov esp, ebp
pop ebx
mov eax, 0x00
ret


PrintError:
push ebp
mov ebp, esp

cmp dword[ebp + 0x0C], 0x01
jne .print
mov eax, 0x01
jmp .end

.print:
push dword[ebp + 0x08]
push ErrorFormat
call [printf]
add esp, 0x08
mov eax, 0x00

.end:
mov esp, ebp
pop ebp
ret 0x08


;Allocates memory and stores the address in the first parameter.
SafePtrAlloc: ;Takes two parameters. First is the Pointer, second is the size to allocate.
push ebp
mov ebp, esp

mov edx, [ebp + 0x08] ;Pointer to be freed

push dword[edx] ;Free pointed to memory
call [free]
add esp, 0x04

push edx ;Save pointer
push dword[ebp + 0x0C] ;Size to allocate in bytes
call [malloc] ;Allocate n-amount
add esp, 0x04 ;Pop parameters
pop edx ;Restore edx
mov [edx], eax ;Move allocated address into edx

mov esp, ebp
pop ebp
retn 0x08

;Sets a pointer to nullptr after freeing its memory
SafePtrFree: ;Takes one parameter. A pointer to a block of memory to free.
push ebp
mov ebp, esp

mov eax, [ebp + 0x08] ;Move pointer into eax
mov edx, eax ;Copy pointer location
push edx ;Save copied pointer

push dword[eax] ;Push the pointed to address
call [free] ;Free the memory
add esp, 0x04
pop edx ;Restore the copied pointer
mov [edx], dword 0x0 ;Set it to nullptr

mov esp, ebp
pop ebp
ret 0x04





[B]If Using Simba (ProSocks v0.2+):

GET:

{$loadlib prosocks}

Function GetPageEx(URL: String): String;
var
S: SSLSocket;
res: ProMemoryStruct;
begin
//S.Timeout := 500; //custom timeout if needed.
Pro_InitSocket(S, nil, nil, nil, nil);
Pro_CreateSocket(S, '');
Pro_SetSSL(S, false, false, true);
Pro_SetURL(S, URL);
Pro_DoGetEx(S, res); //GetRequest

{$IFDEF LAPE}
SetLength(Result, res.size);
MemMove(res.memory^, Result[1], res.size);
{$ELSE}
Result := res.memory;
{$ENDIF}


try
Pro_FreeSocket(S);
except
WriteLn('Unable to Free ' + URL + ' ProSocks Error');
end;
end;



Advanced GET:

//Letting Lape handle the memory allocations instead of the plugin

function PCharToStr(P: PChar): String;
var
L: Integer;
PP: PChar := P;
begin
while (PP^ <> #0) do
begin
Inc(PP); Inc(L);
end;
SetLength(Result, L + 1);
MemMove(P^, Result[1], L);
end;


Function Pro_CustomWriteF(contents: PChar; size: PtrUInt; nmemb: PtrUint; var userp: String): PtrUInt;
var
realsize: PtrUInt;
l: PtrUInt;
ptr: PChar;
begin
ptr := @userp;
realsize := size * nmemb;

if (size <> 0) then
begin
l := Length(UserP);
if (l = 0) then l := 1;
SetLength(UserP, Length(UserP) + realsize);
MemMove(Contents^, UserP[l], realsize); //<3 slacky.
end else
if (ptr <> nil) then
SetLength(UserP, 0);

Result := realsize;
end;

Function Pro_CustomErrorHandlerF(str: PChar; errorcode: LongInt): PtrUInt;
begin
writeln('Error: ' + PCharToStr(Str));
writeln('Error Code: ' + ToStr(ErrorCode));
end;

Function Pro_CustomStrLenF(var str: String): PtrUInt;
begin
Result := Length(str);
end;

var
S: SSLSocket;
Str: String;
begin
S.Timeout := 500; //custom timeout.
S.caller_allocates := true; //Lape allocates all strings and memory.
S.data := @Str; //String to be filled with returned data.

Pro_InitSocket(S, Natify(@Pro_CustomWriteF), Natify(@Pro_CustomWriteF), Natify(@Pro_CustomErrorHandlerF), Natify(@Pro_CustomStrLenF));
Pro_CreateSocket(S, '');
Pro_SetSSL(S, false, true);
Pro_SetURL(S, 'https://villavu.com/forum/');
Pro_DoGet(S);
Pro_FreeSocket(S);

writeln(Str);
end.



GET (Custom Headers):

{$loadlib prosocks}

var
S: SSLSocket;
res: ProMemoryStruct;
begin
Pro_InitSocket(S, nil, nil, nil, nil);
Pro_CreateSocket(S, '');
Pro_SetSSL(S, false, false, true);
Pro_SetURL(S, 'https://villavu.com/forum/');
Pro_SetHeader(S, 'Accept', 'text/html', false); //custom header.
Pro_SetHeader(S, 'Connection', 'keep-alive', false); //custom header.
Pro_DoGetEx(S, res);
writeln(res.memory);
Pro_FreeSocket(S);
end.



POST (Cookie handling as well):

{$loadlib prosocks}

var
S: SSLSocket;
MS: ProMemoryStruct;
begin
Pro_InitSocket(S, nil, nil, nil, nil);
Pro_CreateSocket(S, '');
Pro_SetCookies(S, 'Cookies.txt', 'Cookies.txt'); //allow cookies.
Pro_SetSSL(S, false, false, true);
Pro_SetURLFollow(S, true); //follow redirects.

Pro_SetURL(S, 'https://facebook.com');
Pro_DoGet(S); //dummy GET (used in the OAuth protocol)

Pro_SetURL(S, 'https://www.facebook.com/login.php?login_attempt=1&amp;next=https%3A%2F%2Fwww.f acebook.com%2Fmessages%2F');
Pro_AddParameter(S, 'id', 'login_form', false);
Pro_AddParameter(S, 'trynum', '1', false);
Pro_AddParameter(S, 'email', 'email@hotmail.com', false);
Pro_AddParameter(S, 'pass', '****', false);
Pro_DoPost(S);

Pro_SetURL(S, 'https://www.facebook.com/messages/'); //private page.. to test if we logged in successfully..
Pro_DoGetEx(S, MS);
writeln(MS.memory); //save to a file.html and open the file in the browser. ;)
Pro_FreeSocket(S);
end.


SMTP (Sending Emails.. Supports: CC, BCC, Attachments, MIME, etc..):

{$loadlib prosocks}
var
S: SSLSocket;
begin
Pro_InitSocket(S, nil, nil, nil, nil); //nil for PS.
Pro_CreateSocket(S, ''); //default user agent.
Pro_SetVerbose(S, True); //debugging enabled. Not needed.
Pro_SetSSL(S, false, false, true);
Pro_SMTP(S, 'smtps://smtp.gmail.com', 'user@gmail.com', '****', 'Brandon T', 'to@gmail.com', 'cc', 'bcc', 'Subject', 'Message', 'text/plain; charset=UTF-8', 'Attachment.ext', 'application/x-msdownload; charset=UTF-8');
Pro_FreeSocket(S);
end.



POP3 (Receiving Emails):

{$loadlib prosocks}

var
S: SSLSocket;
MS: ProMemoryStruct;
begin
Pro_InitSocket(S, nil, nil, nil, nil); //nil for PS.
Pro_CreateSocket(S, ''); //default user agent.
Pro_SetVerbose(S, True); //debugging enabled. Not needed.
Pro_SetSSL(S, false, false, true);
Pro_SetURL(S, 'pop.gmail.com');
Pro_SetLogin(S, 'MyEmail@gmail.com', 'MyPassword');
Pro_PerformEx(S, MS);
writeln(MS.memory); //Print results.
Pro_FreeSocket(S);



List of Available Functions & Definitions:


type ProWritePtr = Function(contents: PChar; size: PtrUInt; nmemb: PtrUint; var userp: String): PtrUInt;
type ProErrorHandlerPtr = Function(str: PChar; errorcode: LongInt): PtrUInt;
type ProLenPtr = Function(var Str: String): PtrUInt;

{$IFNDEF LAPE}
type
ProMemoryStruct = record
memory: PChar;
size: PtrUInt;
end;
{$ELSE}
type
ProMemoryStruct = packed record
memory: PChar;
size: PtrUInt;
end;
{$ENDIF}

{$IFNDEF LAPE}
type
SSLSocket = record
curl_handle: PtrUInt;
headers: PChar;
data: PChar;
params: PChar;
LengthFunc: ProLenPtr;
ErrorHandlerFunc: ProErrorHandlerPtr;
WriteFunc: ProWritePtr;
HeaderFunc: ProWritePtr;
hdrs: PChar;
Timeout: Cardinal;
Port: Word;
caller_allocates: Boolean;
end;
{$ELSE}
type
SSLSocket = packed record
curl_handle: PtrUInt;
headers: PChar;
data: PChar;
params: PChar;
LengthFunc: ProLenPtr;
ErrorHandlerFunc: ProErrorHandlerPtr;
WriteFunc: ProWritePtr;
HeaderFunc: ProWritePtr;
hdrs: PChar;
Timeout: Cardinal;
Port: Word;
caller_allocates: Boolean;
end;
{$ENDIF}

//all parameters for this function are to be set to nil in pascal script (except the first parameter). That's because PS doesn't have "natify" or "native".
Procedure Pro_InitSocket(var curl_info: SSLSocket; WriteFunc: ProWritePtr; HeaderFunc: ProWritePtr; ErrorHandlerFunc: ProErrorHandlerPtr; StrLenFunc: ProLenPtr);

Procedure Pro_CreateSocket(var curl_info: SSLSocket; useragent: String);
Procedure Pro_FreeSocket(var curl_info: SSLSocket);
Procedure Pro_SetURLFollow(var curl_info: SSLSocket; follow: Boolean);
Procedure Pro_SetSSL(var curl_info: SSLSocket; try_set: Boolean; verifypeer: Boolean; verifyhost: Boolean);
Procedure Pro_SetCookies(var curl_info: SSLSocket; const cookiejar: String; const cookiefile: String);
Procedure Pro_SetHeaderCapture(var curl_info: SSLSocket; enable: boolean);
Function Pro_SetHeader(var curl_info: SSLSocket; const key: String; const value: String): Boolean;
Procedure Pro_CustomRequest(var curl_info: SSLSocket; const request: String);
Procedure Pro_SetNoBody(var curl_info: SSLSocket; enable: Boolean);
Procedure Pro_SetVerbose(var curl_info: SSLSocket; enable: Boolean);
Function Pro_GetHostLocation(var address: String; var buffer: String): String;
Function Pro_GetRequestLocation(var address: String; var buffer: String): String;
Procedure Pro_SetURL(var curl_info: SSLSocket; const URL: String);
Procedure Pro_SetUpload(var curl_info: SSLSocket; enable: Boolean);
Procedure Pro_SetLogin(var curl_info: SSLSocket; const user: String; const pwd: String);
Procedure Pro_ClearParameters(var curl_info: SSLSocket);
Function Pro_AddParameter(var curl_info: SSLSocket; const key: String; const value: String; escape: Boolean): Boolean;
Function Pro_DoGet(var curl_info: SSLSocket): PChar;
Procedure Pro_DoGetEx(var curl_info: SSLSocket; var Res: ProMemoryStruct);
Function Pro_DoPost(var curl_info: SSLSocket): PChar;
Procedure Pro_DoPostEx(var curl_info: SSLSocket; var Res: ProMemoryStruct);
Function Pro_Perform(var curl_info: SSLSocket): PChar;
Procedure Pro_PerformEx(var curl_info: SSLSocket; var Res: ProMemoryStruct);
Function Pro_GetHeaders(var curl_info: SSLSocket): PChar;
Procedure Pro_GetHeadersEx(var curl_info: SSLSocket; var Res: ProMemoryStruct);
Function Pro_SMTP(var curl_info: SSLSocket; url, user, pwd, name, recipient, cc, bcc, subject, body, bodymime, file, filemime: PChar): Boolean;
Procedure Pro_MSTPC(var curl_info: SSLSocket; var Res: ProMemoryStruct);




If using C/C++ (Prosocks v.0.2+):

//
// main.cpp
// TestSSL
//
// Created by Brandon T on 2015-10-11.
// Copyright © 2015 SRL. All rights reserved.
//

#include <dlfcn.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>



#define LOAD_FUNC(MODULE, PTR) (PTR = (decltype(PTR))dlsym(MODULE, #PTR))


int main(int argc, const char * argv[])
{
void* module = dlopen("/Users/Brandon/Desktop/libProSocks.dylib", RTLD_LAZY);

if (module)
{
printf("All good\n");

LOAD_FUNC(module, Curl_InitSocket);
LOAD_FUNC(module, Curl_CreateSocket);
LOAD_FUNC(module, Curl_FreeSocket);
LOAD_FUNC(module, Curl_SetURLFollow);
LOAD_FUNC(module, Curl_SetSSL);
LOAD_FUNC(module, Curl_SetCookies);
LOAD_FUNC(module, Curl_SetHeaderCapture);
LOAD_FUNC(module, Curl_SetHeader);
LOAD_FUNC(module, Curl_CustomRequest);
LOAD_FUNC(module, Curl_SetNoBody);
LOAD_FUNC(module, Curl_SetVerbose);
LOAD_FUNC(module, Curl_SetVerbose);
LOAD_FUNC(module, Curl_GetHostLocation);
LOAD_FUNC(module, Curl_GetRequestLocation);
LOAD_FUNC(module, Curl_SetURL);
LOAD_FUNC(module, Curl_SetUpload);
LOAD_FUNC(module, Curl_SetLogin);
LOAD_FUNC(module, Curl_ClearParams);
LOAD_FUNC(module, Curl_AddParameter);
LOAD_FUNC(module, Curl_DoGet);
LOAD_FUNC(module, Curl_DoPost);
LOAD_FUNC(module, Curl_Perform);
LOAD_FUNC(module, Curl_GetHeaders);
LOAD_FUNC(module, Curl_SMTP);



CurlSock sock = {0};
Curl_InitSocket(&sock, nullptr, nullptr, nullptr, nullptr);
Curl_CreateSocket(&sock, "");
Curl_SetVerbose(&sock, true);
Curl_SetSSL(&sock, false, false, true);
Curl_SMTP(&sock, "smtps://smtp.gmail.com", "MyEmail@gmail.com", "MyPassword", "Brandon T", "Receipient@gmail.com", nullptr, nullptr, "Subject", "Message", "text/plain; charset=UTF-8", nullptr, nullptr);

Curl_FreeSocket(&sock);


dlclose(module);
}
else
{
printf("%s\n", dlerror());
}

return 0;
}


Yup.. You can now use SSL and TLS without having to download addition crap. You can send emails directly from Simba, etc.. Gmail, Yahoo, AOL, Hotmail/Live/Outlook.. Anything..

NKN
04-20-2014, 03:02 PM
Great work as usual.

Ian
04-20-2014, 07:39 PM
Looks nice Brandon!

Should the port in SMTP.Create be kept at 465?

Edit: Works! :D

http://i.imgur.com/GwOE4cc.png

Janilabo
04-20-2014, 09:18 PM
Daaamn buddy, it is pretty amazing how much you get done in so little time...
Come on man, share that time machine with us! You really are from the future. :p

I repped you with some weird message accidentally...
..I blame this stupid new laptop of mine - it has got keyboard design from hell!
Ment to give you better description to the points, oh well.

Good work once again, Brandon.

-Jani

Rich
04-20-2014, 10:50 PM
So much can be done with the emailing functionality in terms of scripts for Runescape, like reporting back to the user when there's a problem with the script or even getting real time input from the user. Awesome work man!

Turpinator
04-20-2014, 10:55 PM
So that means emails directly through simba? yaaay. :)

as well as checking? more yays. can make scripts do what i want meow. except it seems like alot of work to set that all up.

annyway. great job brandon. :)

Rich
04-20-2014, 11:17 PM
So that means emails directly through simba? yaaay. :)

as well as checking? more yays. can make scripts do what i want meow. except it seems like alot of work to set that all up.

annyway. great job brandon. :)Not really that much work to do at all. All you need to do is download the attachment in the OP and save Socks.simba in your includes folder :)

Brandon
04-20-2014, 11:36 PM
@Jani, no worries. :D Glad you guys like it. No you can make the port whatever you want as long as the server you're talking to is using that port.


25 = smtp
465 = SSL
587 = TLS
80 = HTTP

Of course it can be different but yeah. Google and most providers use 465 or 587 for communication so I used that in the sample script. If you use this as a server socket then you can listen on whatever port you want for incoming connections.


There are only 5 functions (Create, Connect, Read, Write, Accept, IsPending). All others were derived from those.

It's not hard to set up. It's one file you download and you just include it in your script. The "sample" is very very small. Include looks messy as hell but efficient.

It just looks like a lot because there's multiple languages on the OP to demonstrate the flexibility of the module.



SMTP.Create //calls Pro_CreateSocket and Pro_ConnectSocket in SSL23_CLIENT_METHOD mode to establish a connection.
SMTP.Free //calls Pro_CloseSocket & Pro_FreeSocket to cleanup the sockets.
SMTP.SetSubject //set the email subject (optional)
SMTP.SetMessage //set the email body/message (optional)
SMTP.SetFromName //set the name you'd like the recipient to see (optional)
SMTP.SetToName //set the name of the person you are sending to (optional)
SMTP.SetBufferSize //set the internal buffer size. 512 is default (optional)
SMTP.SendMail //send the mail out.


HTTPS.Create //calls Pro_CreateSocket and Pro_ConnectSocket in SSL23_CLIENT_METHOD mode to establish a connection.
HTTPS.Free //calls Pro_CloseSocket & Pro_FreeSocket to cleanup the sockets.
HTTPS.ClearParameters //parameters are http get/post parameters.
HTTPS.GetParameter //retrieves a parameter set on the socket. Example: User-Agent, Accept-Language, Accept-Charset, etc..
HTTPS.SetParameter //sets a parameter on the socket. Example: User-Agent, Accept-Language, Accept-Charset, etc..
HTTPS.GetHeader //get a single header field.
HTTPS.CreateGetHeader //create a get request header.
HTTPS.GetPage //reads html via chunk transfer encoding or straight. Handles all cases
HTTPS.GetRawPage //returns the raw socket data. Does not parse it


type
SSLSocketType = ( //a list of the types of socket you can choose from.
TLS1_CLIENT_METHOD,
TLS1_SERVER_METHOD,
TLS11_CLIENT_METHOD,
TLS11_SERVER_METHOD,
SSL2_CLIENT_METHOD,
SSL2_SERVER_METHOD,
SSL3_CLIENT_METHOD,
SSL3_SERVER_METHOD,
SSL23_CLIENT_METHOD, //most compatible and the best.
SSL23_SERVER_METHOD //most compatible and the best.
);


type
SSLSocket = record
sock: Cardinal; //handle to the raw underlying socket. Can be used with other API's. Do not fill this in.
ssl: Cardinal; //SSL pointer to the underlying SSL instance. Can be used with other API's. Do not fill this in.
ctx: Cardinal; //Same as SSL pointer. It's a context pointer for use with other API's. Do not fill this in.

address: PChar; //Determines what IP to connect to. Must be filled in.
port: Word; //Determines what port to connect to. Must be filled in.

connected: Boolean; //tells you if you're connected or not. Do not fill this in.
socktype: SSLSocketType; //Type of socket you'd like. Must be filled in.
end;


//actual plugin functions..

Function Pro_CreateSocket(ssl_info: ^SSLSocket): Boolean; //Creates the underlying socket.
Function Pro_ConnectSocket(ssl_info: ^SSLSocket): Boolean; //Connects to the address and port with SSL enabled.
Function Pro_CloseSocket(ssl_info: ^SSLSocket): Boolean; //Closes the underlying socket. Does not need calling if FreeSocket is called.
Function Pro_FreeSocket(ssl_info: ^SSLSocket): Boolean; //Frees and destroys both SSL and the underlying socket.
Function Pro_ReadSocket(ssl_info: ^SSLSocket; Buffer: PChar; BuffSize: Integer): Integer; //Reads BuffSize amount of bytes into 'Buffer'. Returns amount of bytes actually read.
Function Pro_WriteSocket(ssl_info: ^SSLSocket; Buffer: String; BuffSize: Integer): Integer; //Writes BuffSize bytes from 'buffer' into the socket. Returns amount of bytes actually written.
Function Pro_AcceptSocket(ssl_info: ^SSLSocket): Boolean; //Accepts a socket if in listening/server mode.
Function Pro_IsPendingSocket(ssl_info ^SSLSocket): Boolean; //Returns if there is data waiting to be written or read to/from the socket.



The only time you would use and of the Pro_* functions is if you plan to do raw communication outside of what's already provided for you.

Flight
04-20-2014, 11:54 PM
Would I be a noob for asking if this can communicate with Github directly?

Brandon
04-21-2014, 12:06 AM
Would I be a noob for asking if this can communicate with Github directly?

I'm not sure what you mean by communicate "directly". It is a raw socket API so you can pretty much do whatever you like. In the sample, I showed it fetching data from github. You can not only do get requests, but you can also do posts as well.. Downloading files, etc.. Anything you can do with a regular socket, you will be able to do with this one.

Flight
04-21-2014, 12:12 AM
I'm not sure what you mean by communicate "directly". It is a raw socket API so you can pretty much do whatever you like. In the sample, I showed it fetching data from github. You can not only do get requests, but you can also do posts as well. Anything you can do with a regular socket, you will be able to do with this one.

Sounds good. I remember asking before why Simba couldn't download files from Github and I was told it's because of something to do with this?

Brandon
04-21-2014, 12:22 AM
Sounds good. I remember asking before why Simba couldn't download files from Github and I was told it's because of something to do with this?


Yup. If you look at github URL's, they use HTTPS. Simba's sockets do not have SSL enabled by default and requires you to install OpenSSL. I tried installing it and placing it in Simba's plugins folder, in my path environment.. nothing worked so I just compiled it and made this plugin.

Yeah to download from github with this is as easy as:


{$I Socks.Simba}

var
HT: HTTPS;
begin
HT.Create('https://raw.githubusercontent.com/Brandon-T/DXI/master/LICENSE', 443);
writeln(HT.GetPage); //download a page. Do NOT have to only download pages.
HT.Free;
end.


That is equivalent to:


{$I Socks.Simba}

var
HT: HTTPS;
Str: String;
begin
HT.Create('raw.githubusercontent.com', 443);
Str := 'GET /Brandon-T/DXI/master/LICENSE HTTP/1.1' + #13#10;
Str := Str + 'Host: raw.githubusercontent.com' + #13#10;

Pro_WriteSocket(@HT.ssl_info, @Str[1], Length(Str));

while(Pro_ReadSocket(@HT.ssl_info, @Buffer[0], Length(Buffer)) > 0) do
begin
writeln(Buffer); //or save it to a file or whatever.. Buffer holds bytes. Can be any type of file or content.

if (Pro_IsPending(@HT.ssl_info)) then
break;
end;

HT.Free;
end.



The same can be done for posting. You can login to websites like that, etc.

Turpinator
04-21-2014, 12:55 AM
Not really that much work to do at all. All you need to do is download the attachment in the OP and save Socks.simba in your includes folder :)

var
MS: SMTP;
HT: HTTPS;
begin
MS.Create('smtp.gmail.com', 465, 'ICantChooseUsernames@gmail.com', '*****password*****', 'ICantChooseUsernames@gmail.com', 'Testing Simba Mail');
MS.SetMessage('Hey there, just testing a message.');
MS.SetFromName('Brandon');
MS.SetToName('Brandon');
MS.SendMail;
MS.Free;
end. -- thats still work. but meh.

Brandon; you should add POP3 checking to the 'include' too. thatd be great. ;)

Brandon
04-21-2014, 02:04 AM
Brandon; you should add POP3 checking to the 'include' too. thatd be great. ;)


Give me a bit and I'll figure out all the headers for POP3. I haven't done that in YEARS (VB times)! Same with IMAP but I remember it being very easy..

I just whipped up something in a couple minutes quick:


Procedure ReadSocket(ssl_info: ^SSLSocket);
var
Buffer: String;
Bytes_Read: Integer;
Begin
SetLength(Buffer, 512);
For Bytes_Read := 1 To 512 Do
Buffer[Bytes_Read] := #0;

While((Bytes_Read := Pro_ReadSocket(ssl_info, @Buffer[1], 512)) > 0) Do
Begin
Buffer := Trim(Buffer);
writeln(Buffer);
If (Not Pro_IsPendingSocket(ssl_info)) Then
break;
End;
End;

var
ssl_info: SSLSocket;
Address: String;
Buffer: String;
begin
Address := 'pop.gmail.com';
ssl_info.port := 995;
ssl_info.address := @Address[1];
ssl_info.socktype := SSLSocketType.SSL23_CLIENT_METHOD;
Pro_CreateSocket(@ssl_info);
Pro_ConnectSocket(@ssl_info);

ReadSocket(@ssl_info);

Buffer := 'USER ' + 'ICantChooseUsernames@gmail.com' + #13#10;
Pro_WriteSocket(@ssl_info, Buffer, Length(Buffer));
ReadSocket(@ssl_info);

Buffer := 'PASS ' + '****password****' + #13#10;
Pro_WriteSocket(@ssl_info, Buffer, Length(Buffer));
ReadSocket(@ssl_info);

Buffer := 'LIST' + #13#10; //list the options/emails.. Use STAT to figure out allocation size for all messages.
Pro_WriteSocket(@ssl_info, Buffer, Length(Buffer));
ReadSocket(@ssl_info);

Buffer := 'RETR 1' + #13#10; //retrieve command. (I think). It gets the 1st mail.
Pro_WriteSocket(@ssl_info, Buffer, Length(Buffer));
ReadSocket(@ssl_info);

Buffer := 'QUIT' + #13#10;
Pro_WriteSocket(@ssl_info, Buffer, Length(Buffer));
ReadSocket(@ssl_info);

Pro_CloseSocket(@ssl_info);
Pro_FreeSocket(@ssl_info);
end.



Don't mind the comments. They're there so I don't forget what I was doing..

I just have to parse headers and check the responses properly like for the mail client and it'll be good.. Pretty neat.. Far easier than SMTP. The HTTP header parser should work on this IIRC. I'll look at it in a sec.

Turpinator
04-21-2014, 02:48 AM
Give me a bit and I'll figure out all the headers for POP3. I haven't done that in YEARS (VB times)! Same with IMAP but I remember it being very easy..

I just whipped up something in a couple minutes quick:


Don't mind the comments. They're there so I don't forget what I was doing..

I just have to parse headers and check the responses properly like for the mail client and it'll be good.. Pretty neat.. Far easier than SMTP. The HTTP header parser should work on this IIRC. I'll look at it in a sec.

coo. ;)

core
04-21-2014, 04:17 AM
I saw this thread (http://villavu.com/forum/showthread.php?t=95086&p=1157180#post1157180) over in SRL Development, and wrote a pure Simba mailer for fun. :)
Obviously, implementing SSL/TLS is a huge undertaking, and I'm not up to that task at the moment.
For SMTP servers that don't require authentication or encryption though, it works like a charm.

Leave it to brandon to do the "huge undertaking" part. Awesome work!

Frement
04-21-2014, 05:06 AM
I must ask, where do you get all the free time?

slacky
04-21-2014, 06:44 AM
Good job, this might come in handy one day! :)

caused
04-21-2014, 12:53 PM
I tried it with gmx and it doesnt seem to work :X.. When using port 465 I get the Output:

220 gmx.com (mrgmx102) Nemesis ESMTP Service ready
501 Syntax error in parameters or arguments
503 Bad sequence of commands
500 Syntax error, command unrecognized
500 Syntax error, command unrecognized
503 Bad sequence of commands
502 Command not implemented
503 Bad sequence of commands
503 Bad sequence of commands
500 Syntax error, command unrecognized
500 Syntax error, command unrecognized

And with 587(suggested by gmx) I dont get any debug output at all. And no mail being sent

Brandon
04-21-2014, 02:02 PM
@Everyone, thanks :D


I tried it with gmx and it doesnt seem to work :X.. When using port 465 I get the Output:
And with 587(suggested by gmx) I dont get any debug output at all. And no mail being sent



EDIT: I changed the SMTP.SendMail to (I updated the OP to reflect the changes):


Str := 'EHLO ' + self.__Address + #13#10; //line 154 for me.
Pro_WriteSocket(@self.__ssl_info, Str, Length(Str));
self.__PrintSocket();

//and

Str := Str + 'Subject: ' + self.__Subject + #13#10#13#10; //line 186 for me.


and it works for gmx. Apparently gmx just didn't support the 'HELO' command.



{$I Socks.Simba}

var
MS: SMTP;
begin
//ESMTP - Extended SMTP
MS.Create('smtp.gmx.us', 465, 'ggzz@gmx.us', '***Password***', 'ggzz@gmx.us', 'SUBJECT');
MS.SetMessage('My Message');
MS.SetFromName('ggzz');
MS.SetToName('Brandon');
MS.SendMail;
MS.Free;

//SMTP - Plain SMTP
MS.Create('smtp.gmail.com', 465, 'ICantChooseUsernames@gmail.com', '***Password***', 'ICantChooseUsernames@gmail.com', 'Testing Simba Mail');
MS.SetMessage('Hey there, just testing a message.');
MS.SetFromName('Brandon');
MS.SetToName('Brandon');
MS.SendMail;
MS.Free;
end.

http://i.imgur.com/9evGcUF.png


Few minor details like mail size can be specified. Reading how the server determines end of DATA section, etc.. The above should work though. I tested it.

HELO command is far cleaner than EHLO. EHLO is used to display server details and HELO is just for identification.. It's stupid that they don't have HELO. Didn't want to use EHLO but it's ok. Works for all now.

core
04-21-2014, 03:39 PM
Just some minor input: SMTP should really be implemented as a finite-state automaton and be reactive to the codes/commands received, rather than just sending out commands regardless of responses. This can trigger abuse detection on some mail providers that can lead to complications. This will also let you dynamically deal with the HELO/EHLO/etc issues, and is incredibly easy to expand on if you want to add more states/transitions in the future.

Kevin
04-21-2014, 03:47 PM
Sexy, sexy sockets. Awesome job, and many thanks for this!

Brandon
04-21-2014, 04:20 PM
Just some minor input: SMTP should really be implemented as a finite-state automaton and be reactive to the codes/commands received, rather than just sending out commands regardless of responses. This can trigger abuse detection on some mail providers that can lead to complications. This will also let you dynamically deal with the HELO/EHLO/etc issues, and is incredibly easy to expand on if you want to add more states/transitions in the future.


Yeah I'll eventually get around to doing that. It was just more work at the time for parsing all the headers and responses. I was lazy and just put something together nice and quick.

caused
04-21-2014, 05:36 PM
@Everyone, thanks :D





EDIT: I changed the SMTP.SendMail to (I updated the OP to reflect the changes):


Str := 'EHLO ' + self.__Address + #13#10; //line 154 for me.
Pro_WriteSocket(@self.__ssl_info, Str, Length(Str));
self.__PrintSocket();

//and

Str := Str + 'Subject: ' + self.__Subject + #13#10#13#10; //line 186 for me.


and it works for gmx. Apparently gmx just didn't support the 'HELO' command.



{$I Socks.Simba}

var
MS: SMTP;
begin
//ESMTP - Extended SMTP
MS.Create('smtp.gmx.us', 465, 'ggzz@gmx.us', '***Password***', 'ggzz@gmx.us', 'SUBJECT');
MS.SetMessage('My Message');
MS.SetFromName('ggzz');
MS.SetToName('Brandon');
MS.SendMail;
MS.Free;

//SMTP - Plain SMTP
MS.Create('smtp.gmail.com', 465, 'ICantChooseUsernames@gmail.com', '***Password***', 'ICantChooseUsernames@gmail.com', 'Testing Simba Mail');
MS.SetMessage('Hey there, just testing a message.');
MS.SetFromName('Brandon');
MS.SetToName('Brandon');
MS.SendMail;
MS.Free;
end.

http://i.imgur.com/9evGcUF.png


Few minor details like mail size can be specified. Reading how the server determines end of DATA section, etc.. The above should work though. I tested it.

HELO command is far cleaner than EHLO. EHLO is used to display server details and HELO is just for identification.. It's stupid that they don't have HELO. Didn't want to use EHLO but it's ok. Works for all now.


Awesome :) Great work.

One more question.

How would you attach a file to an email ? Is that implemented ?

Brandon
04-21-2014, 06:45 PM
Awesome :) Great work.

One more question.

How would you attach a file to an email ? Is that implemented ?


The capabilities of the module itself is there. Are the headers for that implemented in the include? Nope, nope and double nope.. Gotta go through these: http://www.mhonarc.org/~ehood/MIME/MIME.html to do file transfer and understand what --boundary-- is and delimiters for multi-part messages.


Simba itself doesn't have a MIME parser so I would have to write one if I intend to read emails. For writing emails with file attachments, it's not a "massive" task but it does take time for proper implementation. I'll try it soon enough.. as in not today or tomorrow or Wednesday but when I have a day off or another long weekend.

That in itself will take time though. For a single file, it's not too much work to add to the include.

caused
04-22-2014, 11:07 AM
I hate to always be the bearer of bad news :X ..

But the Email Function somtetimes get stuck here:
220 mx.google.com ESMTP w12sm112009888eez.36 - gsmtp
250 mx.google.com at your service
334 VXNlcm5hbWU6
334 UGFzc3dvcmQ6
235 2.7.0 Accepted
... (not doing anything now).

What is the timeout ?

Brandon
04-22-2014, 06:47 PM
I hate to always be the bearer of bad news :X ..

But the Email Function somtetimes get stuck here:
220 mx.google.com ESMTP w12sm112009888eez.36 - gsmtp
250 mx.google.com at your service
334 VXNlcm5hbWU6
334 UGFzc3dvcmQ6
235 2.7.0 Accepted
... (not doing anything now).

What is the timeout ?


Timeout is default timeout. I didn't change it. I'm upgrading the library module atm. Gimmie a couple mins to change some things then I'll look into it. I'm making it support IPV4 and IPV6. Making a options function to set timeouts and non-blocking modes, etc..

caused
04-24-2014, 09:58 AM
Sounds great :).

Really love your plugins :D

rj
04-30-2014, 10:15 PM
Brandon; can this view github pages?

Olly
04-30-2014, 10:44 PM
Brandon; can this view github pages?

http://villavu.com/forum/showthread.php?t=108744&p=1292303#post1292303

rj
05-01-2014, 12:08 AM
http://villavu.com/forum/showthread.php?t=108744&p=1292303#post1292303

hellllllllllllllllllllllllllllllllllllllllllllllll lllllll yea

Brandon
05-01-2014, 12:22 AM
http://villavu.com/forum/showthread.php?t=108744&p=1292303#post1292303

<3 Thanks for covering me while I'm away and what not. Basically thanks for the helpful support.


hellllllllllllllllllllllllllllllllllllllllllllllll lllllll yea

LOL you're a bit too happy there ahaha.

Yeah it does as Olly showed. I haven't had time to compile the new update yet (https://github.com/Brandon-T/ProSocks). The code is on github. It just needs compiling. Works with both C and C++ compilers.

Been developing for an iOS (Objective-C) company and other companies and it's been taking up ALL my free time. Hopefully no bugs in the current plugin.

Olly
05-01-2014, 12:25 AM
Raw github works for me though in Simba :p

http://i.imgur.com/HruCVAd.png

Brandon
05-01-2014, 12:28 AM
Raw github works for me though in Simba :p

http://i.imgur.com/HruCVAd.png


How'd you do that? Have SSL installed in Plugins folder?

Olly
05-01-2014, 12:31 AM
How'd you do that? Have SSL installed in Plugins folder?

Nope, nothing special just the default SRL plugins. I just went and tested it.

Brandon
05-01-2014, 12:47 AM
Nope, nothing special just the default SRL plugins. I just went and tested it.


You're right.. That does indeed work.. but still no secure connection..



var
Sock: Integer;

Address: String;
Username: String;
Password: String;
Receiver: String;
FromName: String;
ToName: String;
Subject: String;
Message: String;
begin
//This line below works..
writeln(GetPage('https://raw.githubusercontent.com/Brandon-T/ProSocks/master/README.md'));


Address := 'smtp.gmail.com';
Username := 'ICantChooseUsernames@gmail.com';
Password := '****Password****';
Receiver := 'ICantChooseUsernames@gmail.com';
FromName := 'Brandon';
ToName := 'Brandon';
Subject := 'Test mail';
Message := 'Hello there..';




Sock := CreateSocket;
ConnectSocket(Sock, Address, '465'); //Can't connect to SSL port. Port 25 will give a response but 465 will disconnect.
SetSocketTimeout(Sock, 2500);



//------------------------------------------------------

SendSocket(Sock, 'EHLO ' + Address + #13#10);
writeln(RecvSocket(Sock)); //Will crash here with error 10054 http://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx

SendSocket(Sock, 'AUTH LOGIN' + #13#10);
writeln(RecvSocket(Sock));

SendSocket(Sock, Base64Encode(Username) + #13#10);
writeln(RecvSocket(Sock));

SendSocket(Sock, Base64Encode(Password) + #13#10);
writeln(RecvSocket(Sock));

SendSocket(Sock, 'MAIL FROM: <' + Username + '>' + #13#10);
writeln(RecvSocket(Sock));

SendSocket(Sock, 'VRFY ' + Username + #13#10);
writeln(RecvSocket(Sock));

SendSocket(Sock, 'RCPT TO: <' + Receiver + '>' + #13#10);
writeln(RecvSocket(Sock));

SendSocket(Sock, 'DATA' + #13#10);
writeln(RecvSocket(Sock));

SendSocket(Sock, 'From: ' + FromName + '<' + Username + '>' + #13#10);
SendSocket(Sock, 'To: ' + ToName + '<' + Receiver + '>' + #13#10);
SendSocket(Sock, 'Subject: ' + Subject + #13#10#13#10);
SendSocket(Sock, Message + #13#10 + '.' + #13#10);
writeln(RecvSocket(Sock));

SendSocket(Sock, 'QUIT' + #13#10);
writeln(RecvSocket(Sock));




CloseSocket(Sock);
FreeSocket(Sock);
end.

rj
05-01-2014, 01:05 AM
Uhh weird bug here:

{$I Socks.Simba}

var
HT: HTTPS;
begin
HT.Create('https://raw.githubusercontent.com/officerBarbrady/SSInclude/master/Soulsplit/core/tfile.simba', 443);
writeln(HT.GetPage); //download a page. Do NOT have to only download pages.
HT.Free;
end.

For some reason it does not get the top part of the file:

type
TFile = record
path, name, extension, data, realPath:string;
end;

This is the version it gets:

function TFile.exists():boolean;
var
s:TStringArray;
i:Integer;
begin
s := GetFiles(self.path, self.extension);
for i := 0 to high(s) do
if (s[i] = (self.name +'.' + self.extension)) then
exit(true);
end;

procedure TFile.recall(const filePath, fileName, fileExtension:string);
begin
self.path := path;
self.name := name;
self.extension := fileExtension;
self.realPath := filePath + fileName + '.' + fileExtension;
end;

function newFile(const filePath, fileName, fileExtension:string):TFile;
begin
result.path := filePath;
result.name := fileName;
result.extension := fileExtension;
result.realPath := filePath + fileName + '.' + fileExtension;
end;

function TFile.open():integer;
begin
result := openFile(self.realPath, true);
end;

function TFile.getSize():integer;
var
tmpFile:integer;
begin
try
tmpFile := self.open();
result := fileSize(tmpFile);
closeFile(tmpFile);
except
end;
end;

function TFile.readString(const strLength:integer):string;
var
tmpFile:integer;
str:string;
begin
if (not self.exists()) then
exit('');
try
tmpFile := self.open();
ReadFileString(tmpFile, str, strLength);
closeFile(tmpFile);
except
finally
result := str;
end;
end;

function TFile.readString():string; overload;
begin
result := self.readString(self.getSize());
end;

function TFile.rewrite():integer;
begin
try
result := rewriteFile(self.realPath, true);
except
end;
end;

function TFile.setText(const str:string):boolean;
var
tmpFile:integer;
begin
if (not self.exists()) then
exit();
try
tmpFile := self.rewrite();
writeFileString(tmpFile, str);
closeFile(tmpFile);
except
end;
end;

function TFile.parseData(const str1, str2:string):string;
var
str:string;
begin
result := between(str1, str2, self.readString());
end;

function TFile.delete():boolean;
begin
result := deleteFile(self.realPath);
end;

procedure TFile.create(const filePath, fileName, fileExtension, writeData:string;overwrite:boolean);
var
tmpFile:integer;
begin
if (not overwrite) and (self.exists()) then
begin
self.recall(filePath, fileName, fileExtension);
exit();
end;
try
self.path := filePath;
self.name := fileName;
self.extension := fileExtension;
self.realPath := filePath + fileName + '.' + fileExtension;
tmpFile := createFile(self.realPath);
closeFile(tmpFile);
if self.setText(writeData) then
self.data := writeData;
except
end;
end;

procedure TFile.create(const thePath, writeData, fileExtension, thename:string); overload;
var
tmpFile:integer;
begin
try
self.realPath := thePath;
self.name := theName;
self.extension := fileExtension;
tmpFile := createFile(thePath);
closeFile(tmpFile);
if self.setText(writeData) then
self.data := writeData;
except
end;
end;

The type is missing
Thus creating an error in my include :S

Added a extra line and that somehow fixed it -.-

rj
05-01-2014, 07:32 PM
Try using GetRawPage instead and see if it makes a difference. If it does, then I need to fix my header parser.

Just used it, it jumbles up a few words. Also the getPage is now cutting off the type again :/

Brandon;

I replaced the function in the include with you one you posted,

Now I get this in my inventory.simba (downloads interface.simba somehow and other stuff) (it also adds all that stuff in other files and mismatched all of them)


HTTP/1.1 200 OK
Date: Thu, 01 May 2014 19:42:46 GMT
Server: Apache
Content-Security-Policy: default-src 'none'
Access-Control-Allow-Origin: https://render.githubusercontent.com
X-XSS-Protection: 1; mode=block
X-Frame-Options: deny
X-Content-Type-Options: nosniff
Strict-Transport-Security: max-age=31536000
ETag: "148d7ce6046517d98a2d6666081921d5a3816b4b"
Content-Type: text/plain; charset=utf-8
Cache-Control: max-age=300
Content-Length: 13585
Accept-Ranges: bytes
Via: 1.1 varnish
X-Served-By: cache-at51-ATL
X-Cache: MISS
X-Cache-Hits: 0
Vary: Authorization,Accept-Encoding
Expires: Thu, 01 May 2014 19:47:46 GMT
Source-Age: 0
Connection: close

length(self.getTPA()) > 1000);
end;

(*
Author: Officer Barbrady
Description: Gets name of interface
*)

function ssInterface.getName:string;
var
b:TBox;
begin
if (not self.isOpen()) then
exit;
b := self.getBounds();
b.y2 := b.y1 + 40;
result := getSimpleText([2070783, 37375, 65535], b.x1, b.y1, b.x2, b.y2, 'upchars07');
end;

(*
Author: Officer Barbrady
Description: Gets interface description
*)

function ssInterface.getDescription:string;
var
b:TBox;
begin
if (not self.isOpen()) then
exit;
b := self.getBounds();
b.y1 := b.y1 + 80;
result := getSimpleText([2070783], b.x1, b.y1, b.x2, b.y2, 'smallchars07');
end;

(*
Author: Officer Barbrady
Description: Closes interface
*)

procedure ssInterface.close;
var
b:TBox;
text:string;
begin
if (not self.isOpen()) then
exit;
b := self.getBounds();
mouse(b.x2 - 15, b.y1 + 30);
end;

rj
05-01-2014, 08:34 PM
Brandon;

procedure TUpdateSystem.update;
var
i, c:integer;
f:TFile;
p:string;
gitPage: HTTPS;
begin
writeln('Scanning for files to update..');
for i := 0 to high(self) do
begin
gitPage.Create(self[i].link, 443);
writeln(self[i].link);
p := gitPage.GetPage();
gitPage.free();
if (length(p) <> length(self[i].sourceFile.readString())) then
begin
writeln('Updated file ' , self[i].sourceFile.realPath);
if f.create(self[i].sourceFile.Path, self[i].sourceFile.name, 'simba', p, true) then
c := c + 1
else
writeln('Failed to updated file ' , self[i].sourceFile.path , self[i].sourceFile.name , '.simba');
end;
end;
writeln('Finished updating ' , c, ' files');
end;

Does it have something to do with the fact that I use the same type each of the 28 times?







Used array of https works fine now woot :)


Never mind again, it's merging text.simba with part of prayer.simba

Brandon
05-01-2014, 09:11 PM
Never mind again, it's merging text.simba with part of prayer.simba


Try the OP again. I just updated the include (not the plugin). Noticed it was doing the same thing. Your file has nulls written into it OR the server is limiting how much can be read at once. Had to write a MemSet function to reset the buffer too. Simba's string length is USELESS.. As soon as it hits a null, it stops printing regardless of the length of the string. Had to trim each buffer.


Example:

String 'Buffer' has contents: 'hello there #0 brave #0 new #0 world'

The value of Length(Buffer) is: 36.
If you writeln(Buffer), it prints only 'hello there '. It stops at the first null. Anyway, all should be fixed.

I did:

HT.Create('https://raw.githubusercontent.com/officerBarbrady/SSInclude/master/Soulsplit/core/prayer.simba', 443);

writeln(HT.GetPage);

HT.Free;

rj
05-01-2014, 09:19 PM
Try the OP again. I just updated the include (not the plugin). Noticed it was doing the same thing. Your file has nulls written into it OR the server is limiting how much can be read at once. Had to write a MemSet function to reset the buffer too. Simba's string length is USELESS.. As soon as it hits a null, it stops printing regardless of the length of the string. Had to trim each buffer.


Example:

String 'Buffer' has contents: 'hello there #0 brave #0 new #0 world'

The value of Length(Buffer) is: 36.
If you writeln(Buffer) it, it prints only 'hello there '. Stops at the first null.

Do you think that has something to do with some random spacing issues lol:


Exception in Script: Unknown declaration "elseiButton" at line 171, column 7 in file "C:\Simba\Includes\Soulsplit\core\mouse.simba"
Exception in Script: Unknown declaration "tpa" at line 101, column 45 in file "C:\Simba\Includes\soulsplit\misc\simba.simba"
Exception in Script: Unknown declaration "doresult" at line 105, column 27 in file "C:\Simba\Includes\soulsplit\misc\datatypes\string. simba"
Exception in Script: Unknown declaration "doresult" at line 105, column 27 in file "C:\Simba\Includes\soulsplit\misc\datatypes\string. simba"
Exception in Script: Unknown declaration "dofor" at line 154, column 25 in file "C:\Simba\Includes\soulsplit\misc\datatypes\string. simba"
Exception in Script: Unknown declaration "exceptresult" at line 84, column 3 in file "C:\Simba\Includes\Soulsplit\core\text.simba"


Randomly glues some words together

Brandon
05-01-2014, 09:26 PM
Robert;


It works perfectly fine.. Has to be something you are doing incorrectly.


{$I Socks.Simba}

const
URL = 'https://raw.githubusercontent.com/officerBarbrady/SSInclude/master/Soulsplit';

MainFiles = ['Files.txt', 'Soulsplit.simba', 'Updater.simba'];

CoreFiles = ['bank', 'chatbox', 'dtm', 'gametab', 'globals', 'interface', 'inventory',
'login', 'mainscreen', 'math', 'minimap', 'mouse', 'prayer', 'tDirectory',
'text', 'tfile', 'timing'];

MiscFiles = ['Simba', 'debug'];

MiscDataTypeFiles = ['extended', 'extendedarrays', 'integer', 'integerarrays', 'string',
'stringarrays', 't2dstringarray', 'tbox', 'tpoint', 'tpointarrays', 'typemath', 'types'];


Directories = ['C:/Simba/Includes/SoulSplit', '/core', '/misc', '/misc/datatypes'];


Function WriteFile(Path: String; Buffer: String): Boolean;
var
hFile: Integer;
Begin
hFile := RewriteFile(Path, false);
if (hFile > -1) then
begin
WriteFileString(hFile, Buffer);
CloseFile(hFile);
end;
End;

Function GetSoulsplit: Boolean;
var
I: Integer;
HT: Array Of HTTPS;
Begin
CreateDirectory(Directories[0]);
CreateDirectory(Directories[0] + Directories[1]);
CreateDirectory(Directories[0] + Directories[2]);
CreateDirectory(Directories[0] + Directories[3]);


SetLength(HT, Length(MainFiles));
For I := 0 To High(MainFiles) Do
Begin
HT[i].Create(URL + '/' + MainFiles[i], 443);
WriteFile(Directories[0] + '/' + MainFiles[i], HT[i].GetPage);
HT[i].Free;
End;

SetLength(HT, 0);
SetLength(HT, Length(CoreFiles));
For I := 0 To High(CoreFiles) Do
Begin
HT[i].Create(URL + '/core/' + CoreFiles[i] + '.simba', 443);
WriteFile(Directories[0] + Directories[1] + '/' + CoreFiles[i] + '.simba', HT[i].GetPage);
HT[i].Free;
End;

SetLength(HT, 0);
SetLength(HT, Length(MiscFiles));
For I := 0 To High(MiscFiles) Do
Begin
HT[i].Create(URL + '/misc/' + MiscFiles[i] + '.simba', 443);
WriteFile(Directories[0] + Directories[2] + '/' + MiscFiles[i] + '.simba', HT[i].GetPage);
HT[i].Free;
End;

SetLength(HT, 0);
SetLength(HT, Length(MiscDataTypeFiles));
For I := 0 To High(MiscDataTypeFiles) Do
Begin
HT[i].Create(URL + '/misc/datatypes/' + MiscDataTypeFiles[i] + '.simba', 443);
WriteFile(Directories[0] + Directories[3] + '/' + MiscDataTypeFiles[i] + '.simba', HT[i].GetPage);
HT[i].Free;
End;
End;

begin
GetSoulsplit;
end.



It would of course be best if Simba had a way of unzipping zip files. That way you simply download the zip and decompress it rather than each file one by one.


Now for resource intense applications, you can use one socket and just reset the headers every time.

rj
05-02-2014, 12:08 AM
Brandon; it still mismatches the same things :/

Brandon
05-02-2014, 01:17 AM
Brandon; it still mismatches the same things :/

Last time.. Try the post on the OP now. I only updated the include.. God sometimes I just wish Simba would play nicely with C-strings..


I had to replace (the first workaround):


Result := Result + Trim(Buffer); //would replace spaces too ={


with (the second workaround)


Result := Trim(Replace(Result, #0, '', [rfReplaceAll])); //replace NULL chars in strings. Trim only the edges.


again due to the bug mentioned in my previous post.. It should without a doubt work now. I actually tested it extensively this time AND I ran your include -_-

Hopefully I don't need a third..


It's starting to bother me that strings in Simba have lengths that mean nothing.. Anyway, test it and let me know how it goes.

rj
05-02-2014, 02:48 AM
Last time.. Try the post on the OP now. I only updated the include.. God sometimes I just wish Simba would play nicely with C-strings..


I had to replace (the first workaround):


Result := Result + Trim(Buffer); //would replace spaces too ={


with (the second workaround)


Result := Trim(Replace(Result, #0, '', [rfReplaceAll])); //replace NULL chars in strings. Trim only the edges.


again due to the bug mentioned in my previous post.. It should without a doubt work now. I actually tested it extensively this time AND I ran your include -_-

Hopefully I don't need a third..


It's starting to bother me that strings in Simba have lengths that mean nothing.. Anyway, test it and let me know how it goes.

Woot woot works now and compiles thanks a ton!

Olly
05-02-2014, 08:24 PM
It would of course be best if Simba had a way of unzipping zip files. That way you simply download the zip and decompress it rather than each file one by one.


https://github.com/MerlijnWajer/Simba/pull/266

:)

alar82
05-12-2014, 12:21 PM
{{$I Socks.Simba}

var
recv:String;
info:SSLSocket;

procedure Connect(Address: String;Port:Integer);
begin
info.port := Port;
info.address := @Address[1];
info.socktype := SSLSocketType.SSL23_SERVER_METHOD;

Pro_CreateSocket(@info);
Pro_ConnectSocket(@info);
writeln(info);
end;


procedure Read(Address: String;Port:Integer);
begin
info.port := Port;
info.address := @Address[1];
info.socktype := SSLSocketType.SSL23_CLIENT_METHOD;

Pro_ReadSocket(@info, @recv, 512);
end;


procedure Destroy(Address: String;Port:Integer);
begin
info.port := Port;
info.address := @Address[1];
info.socktype := SSLSocketType.SSL23_SERVER_METHOD;

Pro_FreeSocket(@info);
end;


begin
Connect('localhost',80);
repeat
Wait(500);
Read('localhost',80);
writeln(recv);
until(false);
Destroy('localhost',80);
end.


Hi it's me again.
I am trying to make local port and listen to that port constantly.
But it crashes before reading anything.
Help.

Brandon
05-12-2014, 04:08 PM
Hi it's me again.
I am trying to make local port and listen to that port constantly.
But it crashes before reading anything.
Help.

Hello. You have a couple things you shouldn't do because it makes NO difference at all.. Your code is equivalent to:


{$I Socks.Simba}

var
recv:String;
info:SSLSocket;

procedure Connect(Address: String;Port:Integer);
begin
info.port := Port;
info.address := @Address[1];
info.socktype := SSLSocketType.SSL23_SERVER_METHOD;

Pro_CreateSocket(@info);
Pro_ConnectSocket(@info);
writeln(info);
end;


procedure Read();
begin
Pro_ReadSocket(@info, @recv, 512);
end;


procedure Destroy();
begin
Pro_FreeSocket(@info);
end;


begin
Connect('localhost',80);
repeat
Wait(500);
Read();
writeln(recv);
until(false);
Destroy();
end.


Secondly, I cannnot replicate the crash. It is actually working. Where exactly are you getting a crash? The socket on the OP is a blocking socket. If there is nothing to read, it is going to WAIT until there is something to read. So if you are trying to do anything on that Simba that is waiting, it is going to crash because it cannot handle messages while the socket is blocking.

I have non-blocking and async sockets already made. I just need to compile them.. I'll upload it later. It is written in C and the source is at: https://github.com/Brandon-T/ProSocks

You may compile it if you wish or wait until I update the simba include to use it.


That all being said, I cannot replicate any crashing.. Anyone else?

alar82
05-12-2014, 05:35 PM
Hey even my fabulous code works now.
When stick before readsocket this:

Pro_WriteSocket(@info, 'ppyy', 4);
Nothing pops up at debug, soso what now?

Brandon
05-12-2014, 06:05 PM
Hey even my fabulous code works now.
When stick before readsocket this:

Pro_WriteSocket(@info, 'ppyy', 4);
Nothing pops up at debug, soso what now?


You cannot write to your own socket and expect to read back the same values you wrote.. It doesn't work like that. Sockets act like pipes for example:


One is the pipe where you read from and one you write to.

See:

http://i.imgur.com/huSaPgJ.png



In other words, open a new tab, create a socket that listens to that port and address constantly; and prints it..
Open another tab and create a socket that writes to that port and address constantly.

It will work then.. Otherwise, you're using sockets for all the wrong reasons.. You need a "server" that listens for requests and writes responses.. You need a "client" that writes requests and listens for responses.

This is the entire concept behind sockets. One tab is your server, the other tab is your client. It can also be: one simba is your server, one simba is your client. In the case of emails, you are the client, gmail is the server.

alar82
05-12-2014, 07:08 PM
Program Server2;
{$I Socks.Simba}

var
recv:String;
info:SSLSocket;

procedure Connect(Address: String;Port:Integer);
begin
info.port := Port;
info.address := @Address[1];
info.socktype := SSLSocketType.SSL23_SERVER_METHOD;

Pro_CreateSocket(@info);
Pro_ConnectSocket(@info);
writeln(info);
end;


procedure Read();
begin
if Pro_IsPendingSocket(@info)then
begin
writeln('Data recived');
end;
Pro_ReadSocket(@info, @recv, 512);
end;


procedure Destroy();
begin
Pro_FreeSocket(@info);
end;


begin
Connect('localhost',80);
repeat
Wait(500);
Read();
writeln(recv);
until(false);
Destroy();
end.

Program Client2;
{$I Socks.Simba}

var
recv:String;
info:SSLSocket;

procedure Connect(Address: String;Port:Integer);
begin
info.port := Port;
info.address := @Address[1];
info.socktype := SSLSocketType.SSL23_CLIENT_METHOD;

Pro_CreateSocket(@info);
Pro_ConnectSocket(@info);
writeln(info);
end;


procedure Write();
begin
Pro_WriteSocket(@info, 'ppd', 512);
end;


procedure Destroy();
begin
Pro_FreeSocket(@info);
end;


begin
Connect('localhost',80);
repeat
Wait(500);
Write();
//writeln(recv);
until(false);
Destroy();
end.

So they are on diffrent simbas.
Server gives:
{SOCK = 1140, SSL = 78072184, CTX = 78072872, ADDRESS = 0x7F24700 (l), PORT = 80, CONNECTED = True, SOCKTYPE = SSL23_SERVER_METHOD}
Client gives:
{SOCK = 576, SSL = 100356568, CTX = 59930872, ADDRESS = 0xBC705B8 (l), PORT = 80, CONNECTED = False, SOCKTYPE = SSL23_CLIENT_METHOD}

They dosen't seem to be connected(false thing), socket and stuff have diffrent values. Help!!!:confused:

Edit: Can we have without encryption choice, I just wanna send/receive data on localhost.
Mainly I wanto set up cheat engine/simba.

Brandon
05-12-2014, 11:19 PM
Edit: Can we have without encryption choice, I just wanna send/receive data on localhost.
Mainly I wanto set up cheat engine/simba.


Yes you can. On Simba, there is a function list on the left side. Click to expand the sockets section.
Use those.

Btw.. your server code is wrong.. You "never accepted" the client's connection. You need to call "acceptsocket" (Not sure if I exported that in this version of the plugin). However, even in Simba's regular sockets you need to accept each client.


Example (see all of my posts here): http://villavu.com/forum/showthread.php?t=104517


Another example is: http://paste.villavu.com/show/5957/

Sin
08-16-2014, 01:43 PM
http://imagizer.imageshack.com/img673/9005/xG6EOf.jpg

Works perfectly, thank you.

Brandon
08-16-2014, 03:49 PM
http://imagizer.imageshack.com/img673/9005/xG6EOf.jpg

Works perfectly, thank you.

Now this is what I like to see! Creativity and good use! :D damn that looks nice. How'd you get such a weird number?

Sin
08-16-2014, 05:00 PM
http://www.emailtextmessages.com/

Get your provider (mine is Telus) and add your number infront of it.
So my telephone number would be 416*******@msg.telus.com.
I get the alerts directly to my phone when i'm at the gym :D

Brandon
10-08-2014, 10:54 PM
Update for pascal script.. Functions are the same.. elfyyy;

https://github.com/Brandon-T/ProSocks/releases/tag/v0.1


Include (supports both Lape AND PascalScript):


{$loadlib ProSocks}

type
SMTP = record
{$IFNDEF CODEINSIGHT}
Addr: String;
User: String;
EUser: String;
EPass: String;
Rec: String;
FName: String;
TName: String;
Subj: String;
Msg: String;
BuffSize: Integer;
Sock: SSLSocket;
{$ENDIF}
end;

type
HTTPS = record
{$IFNDEF CODEINSIGHT}
Hdrs: Array Of String;
PKeys: Array Of String;
PVals: Array Of String;
Host: String;
Addr: String;
BuffSize: Integer;
Sock: SSLSocket;
{$ENDIF}
end;

{$IFNDEF CODEINSIGHT}
Procedure MemSet(var Buffer: String; Value: Byte; Size: Cardinal);
var
I: Integer;
Begin
For I := 1 To Length(Buffer) Do
Buffer[I] := Chr(Value);
End;

Procedure SMTP_PrintSocket(var this: SMTP);
var
Buffer: String;
Bytes_Read: Integer;
Begin
SetLength(Buffer, this.buffsize);

Repeat
{$IFDEF LAPE}
Bytes_Read := Pro_ReadSocket(this.sock, @buffer[1], this.buffsize);
{$ELSE}
Bytes_Read := Pro_ReadSocket(this.sock, buffer, this.buffsize);
{$ENDIF}

writeln(Trim(Buffer));
MemSet(Buffer, 0, this.buffsize);
If (Pro_BytesPendingSocket(this.sock) <= 0) Then
break;
Until(Bytes_Read <= 0);
End;
{$ENDIF}

Function SMTP_Create(var this: SMTP; Address: String; Port: Word; Username, Password, MailTo, Subject: String): Boolean;
{$IFNDEF LAPE}
var
PSDummy: SSLSocketType;
{$ENDIF}
begin
this.Addr := Address;
this.sock.port := Port;
this.sock.blockmode := true;
this.sock.timeout := 3000;
{$IFDEF LAPE}
this.sock.address := @this.Addr[1];
this.sock.socktype := SSLSocketType.SSL23_CLIENT_METHOD;
{$ELSE}
PSDummy := SSL23_CLIENT_METHOD;
this.sock.address := this.Addr;
this.sock.socktype := Ord(PSDummy);
{$ENDIF}

this.EUser := Base64Encode(Username);
this.EPass := Base64Encode(Password);

this.User := Username;
this.Rec := MailTo;
this.Subj := Subject;
this.BuffSize := 512;

Pro_CreateSocket(this.sock);
Result := Pro_ConnectSocket(this.sock);
end;

Procedure SMTP_Free(var this: SMTP);
begin
Pro_CloseSocket(this.sock);
Pro_FreeSocket(this.sock);
end;

Function SMTP_SendMail(var this: SMTP): Boolean;
var
Str: String;
Begin
If (this.sock.connected) Then
Begin
Str := 'EHLO ' + this.Addr + #13#10;
Pro_WriteSocket(this.sock, Str, Length(Str));
SMTP_PrintSocket(this);

Str := 'AUTH LOGIN' + #13#10;
Pro_WriteSocket(this.sock, Str, Length(Str));
SMTP_PrintSocket(this);
SMTP_PrintSocket(this);

Pro_WriteSocket(this.sock, this.EUser + #13#10, Length(this.EUser) + 2);
SMTP_PrintSocket(this);

Pro_WriteSocket(this.sock, this.EPass + #13#10, Length(this.EPass) + 2);
SMTP_PrintSocket(this);
SMTP_PrintSocket(this);

Str := 'MAIL FROM: <' + this.User + '>' + #13#10;
Pro_WriteSocket(this.sock, Str, Length(Str));
SMTP_PrintSocket(this);

Str := 'VRFY ' + this.User + #13#10;
Pro_WriteSocket(this.sock, Str, Length(Str));
SMTP_PrintSocket(this);

Str := 'RCPT TO: <' + this.Rec + '>' + #13#10;
Pro_WriteSocket(this.sock, Str, Length(Str));
SMTP_PrintSocket(this);

Pro_WriteSocket(this.sock, 'DATA' + #13#10, 6);
SMTP_PrintSocket(this);

Str := 'From: ' + this.FName + '<' + this.User + '>' + #13#10;
Str := Str + 'To: ' + this.TName + '<' + this.Rec + '>' + #13#10;
Str := Str + 'Subject: ' + this.Subj + #13#10#13#10;
Pro_WriteSocket(this.sock, Str, Length(Str));

Pro_WriteSocket(this.sock, this.Msg + #13#10 + '.' + #13#10, Length(this.Msg) + 5);
SMTP_PrintSocket(this);
Pro_WriteSocket(this.sock, 'QUIT' + #13#10, 6);
SMTP_PrintSocket(this);
Result := True;
End;
Result := False;
End;



{$IFNDEF CODEINSIGHT}
Function HTTPS_HexToInt(Hex : String): Integer;
var
Str : String;
Begin;
Str := '$' + Trim(Hex);
Result := StrToInt(Str);
If (Pos('-', Hex) > 0) Then
Result := -Result;
End;

Function HTTPS_GetHost(var this: HTTPS): String;
var
I: Integer;
Begin
Result := this.Addr;
I := Pos('://', Result);
if (I >= 0) then
Result := Copy(Result, I + 3, Length(Result) - I);

I := Pos('/', Result);
if (I > 0) then
Result := Copy(Result, 0, I - 1);
End;

Function HTTPS_GetLocation(var this: HTTPS): String;
var
I: Integer;
Begin
Result := this.Addr;
I := Pos('://', Result);
if (I >= 0) then
Result := Copy(Result, I + 3, Length(Result) - I);

I := Pos('/', Result);
if (I > 0) then
Result := Copy(Result, I + 1, Length(Result) - I);
End;

Function HTTPS_RecvLine(var this: HTTPS): String;
var
Line: String;
C: String;
Begin
SetLength(C, 1);
While(True) Do
Begin
{$IFDEF LAPE}
Pro_ReadSocket(this.sock, @C[1], 1);
{$ELSE}
Pro_ReadSocket(this.sock, C, 1);
{$ENDIF}

If (C[1] = #13) Then
Begin
{$IFDEF LAPE}
Pro_ReadSocket(this.sock, @C[1], 1);
{$ELSE}
Pro_ReadSocket(this.sock, C, 1);
{$ENDIF}
If (C[1] = #10) Then Break;

Line := Line + #13;
End Else
If (C[1] = #10) Then Break;

Line := Line + C[1];
End;

Result := Line;
End;

Function HTTPS_RecvHeader(var this: HTTPS): TStringArray;
var
I: Integer;
Line: String;
Begin
While(True) Do
Begin
Line := HTTPS_RecvLine(this);
If (Length(Line) = 0) Then Exit;

SetLength(Result, Length(Result) + 1);
Result[I] := Line;
Inc(I);
End;
End;

Function HTTPS_FindHeaderValue(var this: HTTPS; LineToFind: String): String;
var
I, H, Position: Integer;
Begin
H := High(this.Hdrs);

For I := 0 To H Do
Begin
Position := Pos(':', this.Hdrs[I]);
If ((Position > 0) And (Copy(this.Hdrs[I], 0, Position - 1) = LineToFind)) Then
Begin
Position := Pos(' ', this.Hdrs[I]);
If (Position <> 0) Then
Begin
Result := Copy(this.Hdrs[I], Position + 1, Length(this.Hdrs[I]) - Position);
Exit;
End;
End;
End;
End;

Function HTTPS_GetHeader(var this: HTTPS; Key: String): String;
Begin
If (Length(this.hdrs) <= 0) Then
this.hdrs := HTTPS_RecvHeader(this);

Result := HTTPS_FindHeaderValue(this, Key);
End;

Function HTTPS_RecvChunkSize(var this: HTTPS): Integer;
var
Line: String;
Position: Integer;
Begin
Line := HTTPS_RecvLine(this);
Position := Pos(';', Line);
If (Position <> 0) Then
Delete(Line, Position, 1);

Result := HTTPS_HexToInt(Line);
End;

Function HTTPS_ReadChunked(var this: HTTPS): String;
var
Encoding: String;
ChunkLength: Integer;
Buffer: String;
Bytes_Read: Integer;
Begin
SetLength(Buffer, this.buffsize);
MemSet(Buffer, 0, this.buffsize);

ChunkLength := 0;
Encoding := Lowercase(HTTPS_GetHeader(this, 'Transfer-Encoding'));

If (Encoding = 'chunked') Then
Begin
ChunkLength := HTTPS_RecvChunkSize(this);
While(ChunkLength <> 0) Do
Begin
{$IFDEF LAPE}
Bytes_Read := Pro_ReadSocket(this.sock, @Buffer[1], ChunkLength);
{$ELSE}
Bytes_Read := Pro_ReadSocket(this.sock, Buffer, ChunkLength);
{$ENDIF}
Result := Result + Copy(Buffer, 0, Bytes_Read);
MemSet(Buffer, 0, this.buffsize);
HTTPS_RecvLine(this);
ChunkLength := HTTPS_RecvChunkSize(this);
End;
End Else
Begin
Encoding := HTTPS_GetHeader(this, 'Content-Length');
If (Length(Encoding) > 0) Then
Begin
ChunkLength := StrToIntDef(Encoding, -1);
If (ChunkLength > 0) Then
Begin
Bytes_Read := 0;

While(Bytes_Read < ChunkLength) Do
Begin
MemSet(Buffer, 0, this.buffsize);
{$IFDEF LAPE}
Bytes_Read := Bytes_Read + Pro_ReadSocket(this.sock, @Buffer[1], this.buffsize);
{$ELSE}
Bytes_Read := Bytes_Read + Pro_ReadSocket(this.sock, Buffer, this.buffsize);
{$ENDIF}
Result := Result + Copy(Buffer, 0, Bytes_Read);

If ((Bytes_Read >= ChunkLength) or (Bytes_Read = 0)) Then
Break;
End;
End;
End Else
Begin
While(True) Do
Begin
{$IFDEF LAPE}
Bytes_Read := Pro_ReadSocket(this.sock, @Buffer[1], this.buffsize);
{$ELSE}
Bytes_Read := Pro_ReadSocket(this.sock, Buffer, this.buffsize);
{$ENDIF}
If (Bytes_Read = 0) Then
Break;
Result := Result + Copy(Buffer, 0, Bytes_Read);
MemSet(Buffer, 0, this.buffsize);
End;
End;
End;
Result := Trim(Replace(Result, #0, '', [rfReplaceAll]));
End;

Function HTTPS_KeyFound(var this: HTTPS; Generic_Key: String): Boolean;
var
I: Integer;
Begin
Result := False;
For I := 0 To High(this.pkeys) Do
Begin
If (this.pkeys[I] = Lowercase(Generic_Key)) Then
Begin
Result := True;
Exit;
End;
End;
End;
{$ENDIF}


Function HTTPS_Create(var this: HTTPS; Address: String; Port: Word): Boolean;
{$IFNDEF LAPE}
var
PSDummy: SSLSocketType;
{$ENDIF}
begin
this.Addr := Address;
this.sock.port := Port;
this.sock.blockmode := true;
this.sock.timeout := 3000;
this.Addr := HTTPS_GetHost(this);

{$IFDEF LAPE}
this.sock.address := @this.Addr[1];
this.sock.socktype := SSLSocketType.SSL23_CLIENT_METHOD;
{$ELSE}
PSDummy := SSL23_CLIENT_METHOD;
this.sock.address := this.Addr;
this.sock.socktype := Ord(PSDummy);
{$ENDIF}

this.Addr := Address;
this.buffsize := 512;
Pro_CreateSocket(this.sock);
Result := Pro_ConnectSocket(this.sock);
End;

Procedure HTTPS_Free(var this: HTTPS);
Begin
Pro_CloseSocket(this.sock);
Pro_FreeSocket(this.sock);
End;

Procedure HTTPS_ClearParameters(var this: HTTPS);
Begin
SetLength(this.pkeys, 0);
SetLength(this.pvals, 0);
End;

Function HTTPS_GetParameter(var this: HTTPS; Parameter: String): String;
var
I: Integer;
Begin
For I := 0 To High(this.pkeys) Do
If (this.pvals[I] = Lowercase(Parameter)) Then
Begin
Result := this.pvals[I];
Break;
End;
End;

Procedure HTTPS_SetParameter(var this: HTTPS; Parameter, Value: String);
var
I, L: Integer;
Exists: Boolean;
Begin
Exists := False;
L := Length(this.pvals);

For I := 0 To L - 1 Do
If (this.pvals[I] = Lowercase(Parameter)) Then
Begin
this.pvals[I] := Lowercase(Parameter);
Exists := True;
Break;
End;

If (Not Exists) Then
Begin
SetLength(this.pkeys, L + 1);
SetLength(this.pvals, L + 1);
this.pkeys[L] := Lowercase(Parameter);
this.pvals[L] := Value;
End;
End;

Function HTTPS_CreateGetHeader(var this: HTTPS): String;
var
I: Integer;
Generic_Keys: Array of String;
Generic_Values: Array of String;
Begin
Generic_Keys := ['Connection', 'User-Agent', 'Accept', 'Accept-Language', 'Accept-Charset', 'Cache-Control'];
Generic_Values := ['close', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11',
'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'en-US,en;q=0.8', 'ISO-8859-1,UTF-8;q=0.7,*;q=0.7',
'no-cache'];

Result := 'GET /' + HTTPS_GetLocation(this) + ' HTTP/1.1' + #13#10;
Result := Result + 'Host: ' + HTTPS_GetHost(this) + #13#10;

For I := 0 To High(Generic_Keys) Do
Begin
If (HTTPS_KeyFound(this, Generic_Keys[I])) Then
Result := Result + this.pkeys[I] + ': ' + this.pvals[I] + #13#10
Else
Result := Result + Generic_Keys[I] + ': ' + Generic_Values[I] + #13#10;
End;

Result := Result + #13#10;
End;

Function HTTPS_GetPage(var this: HTTPS): String;
var
Header: String;
Begin
Header := HTTPS_CreateGetHeader(this);
Pro_WriteSocket(this.sock, Header, Length(Header));
Result := HTTPS_ReadChunked(this);
End;

Function HTTPS_GetRawPage(var this: HTTPS): String;
var
Header: String;
Buffer: String;
Bytes_Read: Integer;
Begin
Header := HTTPS_CreateGetHeader(this);
Pro_WriteSocket(this.sock, Header, Length(Header));
HTTPS_RecvHeader(this);

SetLength(Buffer, this.buffsize);
MemSet(Buffer, 0, this.buffsize);

Repeat
{$IFDEF LAPE}
Bytes_Read := Pro_ReadSocket(this.sock, @Buffer[1], this.buffsize);
{$ELSE}
Bytes_Read := Pro_ReadSocket(this.sock, Buffer, this.buffsize);
{$ENDIF}
Result := Result + Trim(Buffer);
MemSet(Buffer, 0, this.buffsize);
Until(Bytes_Read <= 0);
Result := Trim(Replace(Result, #0, '', [rfReplaceAll]));
End;

Shady?
10-19-2014, 09:10 AM
Hey guys, could anyone give me an example on how to send a POST request using this plugin? Great job on developing it by the way Brandon! I'm finding it really useful already :D

Brandon
10-19-2014, 07:48 PM
Hey guys, could anyone give me an example on how to send a POST request using this plugin? Great job on developing it by the way Brandon! I'm finding it really useful already :D

Give me a sec to deal with the other issues of the plugin such as some headers leaking through. This plugin uses raw BSD sockets so everything is done manually.. ={

For posting, if the URL is right, all you do is set the header, set the parameters and write to the socket instead of reading. After writing, you can read the response. Example in Java: https://villavu.com/forum/showthread.php?t=107109&p=1275581#post1275581


You see how in:


Function HTTPS_GetPage(var this: HTTPS): String;
var
Header: String;
Begin
Header := HTTPS_CreateGetHeader(this); //this line..
Pro_WriteSocket(this.sock, Header, Length(Header));
Result := HTTPS_ReadChunked(this);
End;


it creates the GET header first then writes to the socket. Instead you need to create a POST header then write to the socket.
All parameters in a POST request have a key-value pair and each is separated by an ampersand sign.


Give me a couple minutes and I'll see if I can simplify it greatly. I'll probably also patch the stupid get headers or use libcurl to do it.

If I use libcurl, there'd probably never be any glitches or problems and things will be a ton easier but I'm a kind of DIY-er guy.. We'll see.

Shady?
10-19-2014, 08:26 PM
Give me a sec to deal with the other issues of the plugin such as some headers leaking through. This plugin uses raw BSD sockets so everything is done manually.. ={

For posting, if the URL is right, all you do is set the header, set the parameters and write to the socket instead of reading. After writing, you can read the response. Example in Java: https://villavu.com/forum/showthread.php?t=107109&p=1275581#post1275581


You see how in:


Function HTTPS_GetPage(var this: HTTPS): String;
var
Header: String;
Begin
Header := HTTPS_CreateGetHeader(this); //this line..
Pro_WriteSocket(this.sock, Header, Length(Header));
Result := HTTPS_ReadChunked(this);
End;


it creates the GET header first then writes to the socket. Instead you need to create a POST header then write to the socket.
All parameters in a POST request have a key-value pair and each is separated by an ampersand sign.


Give me a couple minutes and I'll see if I can simplify it greatly. I'll probably also patch the stupid get headers or use libcurl to do it.

If I use libcurl, there'd probably never be any glitches or problems and things will be a ton easier but I'm a kind of DIY-er guy.. We'll see.

That's great to hear! I actually created a couple of functions:

Function HTTPS.CreatePostHeader: String;

All I did there was edit this line Result := 'GET /' + self.__GetLocation(self.__Address) + ' HTTP/1.1' + #13#10; to Result := 'POST /' + self.__GetLocation(self.__Address) + ' HTTP/1.1' + #13#10;
But as I had no idea of what I was doing, it didn't work. I also created a Function HTTPS.PostRawPage: String; which is equal to GetRawPage but it calls self.CreatePostHeader(); instead. Glad to see you're actively developing this !

Brandon
10-20-2014, 07:18 AM
...

Still cross-platform and in development.. I'll be finished everything by tomorrow (i think). Currently, I focused mostly on getting the bug fixed reported by elfffy for PS get-page. You can see the code below for an example of the "new" way of getting a page.
24234

License is GPL3 with the following exception (for developers.. same as the Debian distribution license):


In addition, as a special exception, the copyright holders give
permission to link the code of portions of this program with the
OpenSSL library under certain conditions as described in each
individual source file, and distribute linked combinations including
the two.

You must obey the GNU General Public License in all respects for all
of the code used other than OpenSSL. If you modify file(s) with this
exception, you may extend this exception to your version of the
file(s), but you are not obligated to do so. If you do not wish to do
so, delete this exception statement from your version. If you delete
this exception statement from all source files in the program, then
also delete it here.



I haven't gotten around to writing a proper include yet so I wouldn't be in a hurry to use this, but here is a list of its capabilities:

Lape (memory manager example):

{$loadlib prosocks}

function PCharToStr(P: PChar): String;
var
L: Integer;
PP: PChar := P;
begin
while (PP^ <> #0) do
begin
Inc(PP); Inc(L);
end;
SetLength(Result, L + 1);
MemMove(P^, Result[1], L);
end;

Function Pro_CustomWriteF(contents: PChar; size: PtrUInt; nmemb: PtrUint; var userp: String): PtrUInt;
var
realsize: PtrUInt;
l: PtrUInt;
ptr: PChar;
begin
ptr := @userp;
realsize := size * nmemb;

if (size <> 0) then
begin
l := Length(UserP);
if (l = 0) then l := 1;
SetLength(UserP, Length(UserP) + realsize);
MemMove(Contents^, UserP[l], realsize); //<3 slacky.
end else
if (ptr <> nil) then
SetLength(UserP, 0);

Result := realsize;
end;

Function Pro_CustomErrorHandlerF(str: PChar; errorcode: LongInt): PtrUInt;
begin
writeln('Error: ' + PCharToStr(Str));
writeln('Error Code: ' + ToStr(ErrorCode));
end;

Function Pro_CustomStrLenF(var str: String): PtrUInt;
begin
Result := Length(str);
end;

var
S: SSLSocket;
Str: String;
begin
S.Timeout := 500;
S.caller_allocates := true;
S.data := @Str;
Pro_InitSocket(S, Natify(@Pro_CustomWriteF), Natify(@Pro_CustomWriteF), Natify(@Pro_CustomErrorHandlerF), Natify(@Pro_CustomStrLenF));
Pro_CreateSocket(S, '');
Pro_SetSSL(S, false, true);
Pro_SetURL(S, 'https://villavu.com/forum/');
Pro_DoGet(S);
Pro_FreeSocket(S);

writeln(Str);
end.
end.



Don't mind the pchartostr.. That's just because lape is retarded and can't print pchars like pascal script.. Olly; tell me why..

Other than that, the rest of code is actually optional. It lets lape do the allocations instead of C. These are all callbacks. Whenever the socket receives data, it calls the above functions. The first is for every bit of data it receives. The second function is for headers that it receives and the third is for error handling. If there is an error, it calls that function and passes it a description as well as an error code. The last function is just a wrapper that it calls to get the length of a lape string.

IMO, the lape code is absolute crap (because of the pchar stuff). Not sure how much of an overhead 'native' or 'natify' have in lape but with slacky's suggestion, the lape code is a lot faster now. Still not as fast as the plugin's code.

The much simpler approach which can also be done in Lape is to let C handle the allocations (notice there's no include yet? That's a huge simplification from before. Might not ever need one, who knows.. :D):

PascalScript/Lape:

{$loadlib prosocks} //load the lib.. no include so far..

var
S: SSLSocket;
res: ProMemoryStruct;
begin
Pro_InitSocket(S, nil, nil, nil, nil);
Pro_CreateSocket(S, '');
Pro_SetSSL(S, false, true);
Pro_SetURL(S, 'https://villavu.com/forum/');
Pro_DoGetEx(S, res);
writeln(res.memory);
Pro_FreeSocket(S);
end.



Others functions:
//Pro_AddPostParameter(S: SSLSocket, key, value: String; escapeString: Boolean);
//Procedure Pro_SetURLFollow(S: SSLSocket, follow: Boolean);
//Pro_SetCookies(S: SSLSocket; cookiejar, cookiefile: String);

Those are just a few of the things the plugin contains.. I haven't added the 'GetRequest' parameters yet.. Easy to add. Some other features that it can handle are TLS and SSL requests:

Pop3
Imap
Smtp
Ftp
Https
Http
etc...

Also wrote a multi-plexer for fully asynchronous sockets (not non-blocking/timeout).. but I might leave it out of Simba because I don't see the need for threaded and queue requests..

For now, you can try out some things with it but I'll be finishing the rest of it tomorrow.. Here's the current additions (these are additions onto the current raw SSL plugin.. This API is what will make things way easier for everyone, including me..)


static const char* PascalExports[] =
{
#ifndef CURL_SSL
"AcceptSocket", "Function Pro_AcceptSocket(var ssl_info, ssl_client_info: SSLSocket): Boolean;",
"BindSocket", "Function Pro_BindSocket(var ssl_info: SSLSocket): Boolean;",
"BytesPendingSocket", "Function Pro_BytesPendingSocket(var ssl_info: SSLSocket): Integer;",
"CreateSocket", "Function Pro_CreateSocket(var ssl_info: SSLSocket): Boolean;",
"ConnectSocket", "Function Pro_ConnectSocket(var ssl_info: SSLSocket): Boolean;",
"ListenSocket", "Function Pro_ListenSocket(var ssl_info: SSLSocket): Boolean;",
"SetBlockingSocket", "Function Pro_SetBlockingSocket(var ssl_info: SSLSocket): Boolean;",
"SetTimeoutSocket", "Function Pro_SetTimeoutSocket(var ssl_info: SSLSocket): Boolean;",
"SelectSocket", "Function Pro_SelectSocket(var ssl_info: SSLSocket; Read: Boolean): Integer;",
"CloseSocket", "Function Pro_CloseSocket(var ssl_info: SSLSocket): Boolean;",
"FreeSocket", "Function Pro_FreeSocket(var ssl_info: SSLSocket): Boolean;",
"ReadSocket", "Function Pro_ReadSocket(var ssl_info: SSLSocket; Buffer: PChar; Size: Cardinal): Integer;",
"WriteSocket", "Function Pro_WriteSocket(var ssl_info: SSLSocket; Buffer: String; Size: Cardinal): Integer;",
#else
"Curl_InitSocket", "Procedure Pro_InitSocket(var curl_info: SSLSocket; WriteFunc: ProWritePtr; HeaderFunc: ProWritePtr; ErrorHandlerFunc: ProErrorHandlerPtr; StrLenFunc: ProLenPtr);",
"Curl_CreateSocket", "Procedure Pro_CreateSocket(var curl_info: SSLSocket; useragent: String);",
"Curl_FreeSocket", "Procedure Pro_FreeSocket(var curl_info: SSLSocket);",
"Curl_SetURLFollow", "Procedure Pro_SetURLFollow(var curl_info: SSLSocket; follow: Boolean);",
"Curl_SetSSL", "Procedure Pro_SetSSL(var curl_info: SSLSocket; verifypeer, verifyhost: Boolean);",
"Curl_SetCookies", "Procedure Pro_SetCookies(var curl_info: SSLSocket; const cookiejar: String; const cookiefile: String);",
"Curl_SetHeaderCapture", "Procedure Pro_SetHeaderCapture(var curl_info: SSLSocket; enable: boolean);",
"Curl_SetURL", "Procedure Pro_SetURL(var curl_info: SSLSocket; const URL: String);",
"Curl_AddParameter", "Function Pro_AddPostParameter(var curl_info: SSLSocket; const key: String; const value: String; escape: Boolean): Boolean;",
"Curl_DoGet", "Function Pro_DoGet(var curl_info: SSLSocket): PChar;",
"Curl_DoGetEx", "Procedure Pro_DoGetEx(var curl_info: SSLSocket; var Res: ProMemoryStruct);",
"Curl_DoPost", "Function Pro_DoPost(var curl_info: SSLSocket): PChar;",
"Curl_DoPostEx", "Procedure Pro_DoPostEx(var curl_info: SSLSocket; var Res: ProMemoryStruct);",
"Curl_GetHeaders", "Function Pro_GetHeaders(var curl_info: SSLSocket): PChar",
"Curl_GetHeaders", "Function Pro_GetHeadersEx(var curl_info: SSLSocket): ProMemoryStruct;"
#endif
};

static const char* PascalTypes[] =
{
#ifndef CURL_SSL
"SSLSocketType", "(TLS1_CLIENT_METHOD, TLS1_SERVER_METHOD, TLS11_CLIENT_METHOD, TLS11_SERVER_METHOD, SSL2_CLIENT_METHOD, SSL2_SERVER_METHOD, SSL3_CLIENT_METHOD, SSL3_SERVER_METHOD, SSL23_CLIENT_METHOD, SSL23_SERVER_METHOD);",
"SSLSocket", "{$IFNDEF LAPE}record sock: Cardinal; ssl: Cardinal; ctx: Cardinal; address: PChar; socktype: Integer; timeout: Cardinal; port: Word; connected: Boolean; blockmode: Boolean; end;{$ELSE}packed record sock: Cardinal; ssl: Cardinal; ctx: Cardinal; address: PChar; socktype: SSLSocketType; timeout: Cardinal; port: Word; connected: Boolean; blockmode: Boolean; end;{$ENDIF}"
#else
"ProWritePtr", "Function(contents: PChar; size: PtrUInt; nmemb: PtrUint; var userp: String): PtrUInt;",
"ProErrorHandlerPtr", "Function(str: PChar; errorcode: LongInt): PtrUInt;",
"ProLenPtr", "Function(var Str: String): PtrUInt",
"ProMemoryStruct", "{$IFNDEF LAPE}record memory: PChar; size: PtrUInt; end;{$ELSE}packed record memory: PChar; size: PtrUInt; end;{$ENDIF}",
"SSLSocket", "{$IFNDEF LAPE}record curl_handle: PtrUInt; headers: PChar; data: PChar; params: PChar; LengthFunc: Function(var Str: String): PtrUInt; ErrorHandlerFunc: Function(var str: string; errorcode: LongInt): PtrUInt; WriteFunc: Function(contents: PChar; size: PtrUInt; nmemb: PtrUint; var userp: String): PtrUInt; HeaderFunc: Function(contents: PChar; size: PtrUInt; nmemb: PtrUint; var userp: String): PtrUInt; Timeout: Cardinal; Port: Word; caller_allocates: Boolean; end;{$ELSE}packed record curl_handle: PtrUInt; headers: PChar; data: PChar; params: PChar; LengthFunc: Function(var Str: String): PtrUInt; ErrorHandlerFunc: Function(var str: string; errorcode: LongInt): PtrUInt; WriteFunc: Function(contents: PChar; size: PtrUInt; nmemb: PtrUint; var userp: String): PtrUInt; HeaderFunc: Function(contents: PChar; size: PtrUInt; nmemb: PtrUint; var userp: String): PtrUInt; Timeout: Cardinal; Port: Word; caller_allocates: Boolean; end;{$ENDIF}"
#endif
};

slacky
10-20-2014, 07:24 AM
Brandon:
The params of MemMove is the other way around, assuming your MemCpy is "Dest, Source", where MemMove is "Source, Dest".


Function Pro_CustomWriteF(contents: PChar; size: PtrUInt; nmemb: PtrUint; var userp: String): PtrUInt;
var
realsize: PtrUInt;
l: PtrUInt;
ptr: PChar;
begin
ptr := @userp; //user p is a lape string provided by you. this string will be filled..
realsize := size * nmemb; //sizeof(char) * length = total data size.

if (size <> 0) then
begin
l := Length(UserP);
if (l = 0) then l := 1;
SetLength(UserP, Length(UserP) + realsize); //let lape resize the string appropriately.
MemMove(Contents^, UserP[l], realsize); //let lape fill it with data..
end else
if (ptr <> nil) then
SetLength(UserP, 0);

Result := realsize;
end;


Anyways, good job! :-)

Brandon
10-20-2014, 07:38 AM
Brandon:
The params of MemMove is the other way around, assuming your MemCpy is "Dest, Source", where MemMove is "Source, Dest".


Yes! This is what I needed <3. Updated the post. Now to get lape to print pchars and not their addresses..
This suggestion worked perfectly fine though. I kept thinking it was like the memmove in C where it goes memmove(dest, src, len).. Never thought pascal would switch the parameters like that -_-.

slacky
10-20-2014, 07:49 AM
Yes! This is what I needed <3. Updated the post. Now to get lape to print pchars and not their addresses..
This suggestion worked perfectly fine though. I kept thinking it was like the memmove in C where it goes memmove(dest, src, len).. Never thought pascal would switch the parameters like that -_-.
happy to help.

Ref: «get lape to print pchars and not their addresses»
If I get you right, you wanna changing the behavior of of WriteLn in Lape?(override ToString)

// overrides lapes ToString, and treats PChar as a null-terminated string.
function ToString(P:PChar):String; override;
var
PP: PChar := P;
begin
while not(PP^ = #0) do Inc(PP);

SetLength(Result, PtrUInt(PP)-PtrUInt(P) + 1);
MemMove(P^, Result[1], PtrUInt(PP)-PtrUInt(P));
end;

(*
// Or.. just dereference the PChar
function ToString(P:PChar): String; override;
begin
Result := P^;
end;
*)

var
Arr: Array of Char := ['a','b','c','d','e','f',#0];
begin
WriteLn( @Arr[0] );
end.

Brandon
10-21-2014, 05:03 AM
https://github.com/Brandon-T/ProSocks/releases/tag/v0.2

Done.. I hope.. I'm really tired so I'll only post some examples.. NOT all.. The license (exception added) is now updates as well so there should be no problems.

If you need more examples (Pop3, Imap, etc.. let me know and I can write something up).. For now, I need sleep and the below is what users would use the most..

What the internals of the plugin looks like (this is not an include.. there are no includes for this plugin atm.. it works out of the box):

type ProWritePtr = Function(contents: PChar; size: PtrUInt; nmemb: PtrUint; var userp: String): PtrUInt;
type ProErrorHandlerPtr = Function(str: PChar; errorcode: LongInt): PtrUInt;
type ProLenPtr = Function(var Str: String): PtrUInt;

{$IFNDEF LAPE}
type
ProMemoryStruct = record
memory: PChar;
size: PtrUInt;
end;
{$ELSE}
type
ProMemoryStruct = packed record
memory: PChar;
size: PtrUInt;
end;
{$ENDIF}

{$IFNDEF LAPE}
type
SSLSocket = record
curl_handle: PtrUInt;
headers: PChar;
data: PChar;
params: PChar;
LengthFunc: ProLenPtr;
ErrorHandlerFunc: ProErrorHandlerPtr;
WriteFunc: ProWritePtr;
HeaderFunc: ProWritePtr;
hdrs: PChar;
Timeout: Cardinal;
Port: Word;
caller_allocates: Boolean;
end;
{$ELSE}
type
SSLSocket = packed record
curl_handle: PtrUInt;
headers: PChar;
data: PChar;
params: PChar;
LengthFunc: ProLenPtr;
ErrorHandlerFunc: ProErrorHandlerPtr;
WriteFunc: ProWritePtr;
HeaderFunc: ProWritePtr;
hdrs: PChar;
Timeout: Cardinal;
Port: Word;
caller_allocates: Boolean;
end;
{$ENDIF}

//all parameters for this function are to be set to nil in pascal script (except the first parameter). That's because PS doesn't have "natify" or "native".
Procedure Pro_InitSocket(var curl_info: SSLSocket; WriteFunc: ProWritePtr; HeaderFunc: ProWritePtr; ErrorHandlerFunc: ProErrorHandlerPtr; StrLenFunc: ProLenPtr);

Procedure Pro_CreateSocket(var curl_info: SSLSocket; useragent: String);
Procedure Pro_FreeSocket(var curl_info: SSLSocket);
Procedure Pro_SetURLFollow(var curl_info: SSLSocket; follow: Boolean);
Procedure Pro_SetSSL(var curl_info: SSLSocket; try_set: Boolean; verifypeer: Boolean; verifyhost: Boolean);
Procedure Pro_SetCookies(var curl_info: SSLSocket; const cookiejar: String; const cookiefile: String);
Procedure Pro_SetHeaderCapture(var curl_info: SSLSocket; enable: boolean);
Function Pro_SetHeader(var curl_info: SSLSocket; const key: String; const value: String): Boolean;
Procedure Pro_CustomRequest(var curl_info: SSLSocket; const request: String);
Procedure Pro_SetNoBody(var curl_info: SSLSocket; enable: Boolean);
Procedure Pro_SetVerbose(var curl_info: SSLSocket; enable: Boolean);
Function Pro_GetHostLocation(var address: String; var buffer: String): String;
Function Pro_GetRequestLocation(var address: String; var buffer: String): String;
Procedure Pro_SetURL(var curl_info: SSLSocket; const URL: String);
Procedure Pro_SetUpload(var curl_info: SSLSocket; enable: Boolean);
Procedure Pro_SetLogin(var curl_info: SSLSocket; const user: String; const pwd: String);
Procedure Pro_ClearParameters(var curl_info: SSLSocket);
Function Pro_AddParameter(var curl_info: SSLSocket; const key: String; const value: String; escape: Boolean): Boolean;
Function Pro_DoGet(var curl_info: SSLSocket): PChar;
Procedure Pro_DoGetEx(var curl_info: SSLSocket; var Res: ProMemoryStruct);
Function Pro_DoPost(var curl_info: SSLSocket): PChar;
Procedure Pro_DoPostEx(var curl_info: SSLSocket; var Res: ProMemoryStruct);
Function Pro_Perform(var curl_info: SSLSocket): PChar;
Procedure Pro_PerformEx(var curl_info: SSLSocket; var Res: ProMemoryStruct);
Function Pro_GetHeaders(var curl_info: SSLSocket): PChar;
Procedure Pro_GetHeadersEx(var curl_info: SSLSocket; var Res: ProMemoryStruct);
Function Pro_SMTP(var curl_info: SSLSocket; url, user, pwd, name, recipient, cc, bcc, subject, body, bodymime, file, filemime: PChar): Boolean;
Procedure Pro_MSTPC(var curl_info: SSLSocket; var Res: ProMemoryStruct);



Examples:

Emails with attachment support and mime-type support (html, plain-text, etc..). You can have multiple Recipients, CCs, BCCs by separating each one with \r\n aka #13#10 in PS/Lape.

{$loadlib prosocks}

var
S: SSLSocket;
begin
Pro_InitSocket(S, nil, nil, nil, nil); //nil for PS.
Pro_CreateSocket(S, ''); //default user agent.
Pro_SetVerbose(S, True); //debugging enabled. Not needed.
Pro_SetSSL(S, false, false, true);
Pro_SMTP(S, 'smtps://smtp.gmail.com', 'user@gmail.com', '****', 'Brandon T', 'to@gmail.com', 'cc', 'bcc', 'Subject', 'Message', 'text/plain; charset=UTF-8', 'Attachment.ext', 'application/x-msdownload; charset=UTF-8');
Pro_FreeSocket(S);
end.



GET:

{$loadlib prosocks}

var
S: SSLSocket;
res: ProMemoryStruct;
begin
Pro_InitSocket(S, nil, nil, nil, nil);
Pro_CreateSocket(S, '');
Pro_SetSSL(S, false, false, true);
Pro_SetURL(S, 'https://villavu.com/forum/');
Pro_DoGetEx(S, res);
writeln(res.memory);
Pro_FreeSocket(S);
end.



GET Custom Header:

{$loadlib prosocks}

var
S: SSLSocket;
res: ProMemoryStruct;
begin
Pro_InitSocket(S, nil, nil, nil, nil);
Pro_CreateSocket(S, '');
Pro_SetSSL(S, false, false, true);
Pro_SetURL(S, 'https://villavu.com/forum/');
Pro_SetHeader(S, 'Accept', 'text/plain', false);
Pro_SetHeader(S, 'Connection', 'keep-alive', false);
Pro_DoGetEx(S, res);
writeln(res.memory);
Pro_FreeSocket(S);
end.



POST (complicated example with parameters.. Logs into facebook..):

{$loadlib prosocks}

var
S: SSLSocket;
MS: ProMemoryStruct;
begin
Pro_InitSocket(S, nil, nil, nil, nil);
Pro_CreateSocket(S, '');
Pro_SetCookies(S, 'Cookies.txt', 'Cookies.txt'); //allow cookies.
Pro_SetSSL(S, false, false, true);
Pro_SetURLFollow(S, true); //follow redirects.

Pro_SetURL(S, 'https://facebook.com');
Pro_DoGet(S); //dummy GET (used in the OAuth protocol)

Pro_SetURL(S, 'https://www.facebook.com/login.php?login_attempt=1&amp;next=https%3A%2F%2Fwww.f acebook.com%2Fmessages%2F');
Pro_AddParameter(S, 'id', 'login_form', false);
Pro_AddParameter(S, 'trynum', '1', false);
Pro_AddParameter(S, 'email', 'email@hotmail.com', false);
Pro_AddParameter(S, 'pass', '****', false);
Pro_DoPost(S);

Pro_SetURL(S, 'https://www.facebook.com/messages/'); //private page.. to test if we logged in successfully..
Pro_DoGetEx(S, MS);
writeln(MS.memory); //save to a file.html and open the file in the browser. ;)
Pro_FreeSocket(S);
end.



Notes:
I've tested all of the above. Especially the emailing features.. Worked real hard on that. Let me know how things go for you guys..

Shady?
10-22-2014, 05:32 AM
https://github.com/Brandon-T/ProSocks/releases/tag/v0.2

Done.. I hope.. I'm really tired so I'll only post some examples.. NOT all.. The license (exception added) is now updates as well so there should be no problems.


Wow, I can't being to tell you how much I appreciate this. Great work! This should come in very handy, thank youuu. I'll do some tests, will let you know how it works.

rj
04-15-2015, 05:18 AM
Brandon;

When I use HTTP.getRawPage() it seems to randomly delete spaces from the page causing the code not to compile

For instance:

function isText(Text, theText: TStringArray): Boolean;
vari,k: Integer;

And if I use getPage then I just get something like

HTTP/1.1 200 OK
Date: Wed, 15 Apr 2015 05:15:55 GMT
Server: Apache
Access-Control-Allow-Origin: https://render.githubusercontent.com
Content-Security-Policy: default-src 'none'
X-XSS-Protection: 1; mode=block
X-Frame-Options: deny
X-Content-Type-Options: nosniff
Strict-Transport-Security: max-age=31536000
ETag: "ae2c508f9c1a0aa5cff6dbcf3a300976bfeda682"
Content-Type: text/plain; charset=utf-8
Cache-Control: max-age=300
Content-Length: 2330
Accept-Ranges: bytes
Via: 1.1 varnish
X-Served-By: ca

So I figured I had to use getRawPage


Any idea why it does that? Just read on page 2 I was having the same issue last year but it was fixed, now I'm running into the same issue somehow

Brandon
04-25-2015, 01:12 AM
Brandon;

When I use HTTP.getRawPage() it seems to randomly delete spaces from the page causing the code not to compile

For instance:

function isText(Text, theText: TStringArray): Boolean;
vari,k: Integer;

And if I use getPage then I just get something like

HTTP/1.1 200 OK
Date: Wed, 15 Apr 2015 05:15:55 GMT
Server: Apache
Access-Control-Allow-Origin: https://render.githubusercontent.com
Content-Security-Policy: default-src 'none'
X-XSS-Protection: 1; mode=block
X-Frame-Options: deny
X-Content-Type-Options: nosniff
Strict-Transport-Security: max-age=31536000
ETag: "ae2c508f9c1a0aa5cff6dbcf3a300976bfeda682"
Content-Type: text/plain; charset=utf-8
Cache-Control: max-age=300
Content-Length: 2330
Accept-Ranges: bytes
Via: 1.1 varnish
X-Served-By: ca

So I figured I had to use getRawPage


Any idea why it does that? Just read on page 2 I was having the same issue last year but it was fixed, now I'm running into the same issue somehow

Not sure what you're using or doing but if you use the latest plugin then you can do what the reflection include does as well:



{$loadlib prosocks}

Function GetPageEx(URL: String): String;
var
S: SSLSocket;
res: ProMemoryStruct;
begin
Pro_InitSocket(S, nil, nil, nil, nil);
Pro_CreateSocket(S, '');
Pro_SetSSL(S, false, false, true);
Pro_SetURL(S, URL);
Pro_DoGetEx(S, res);

{$IFDEF LAPE}
SetLength(Result, res.size);
MemMove(res.memory^, Result[1], res.size);
{$ELSE}
Result := res.memory;
{$ENDIF}


try
Pro_FreeSocket(S);
except
WriteLn('Unable to Free ' + URL + ' ProSocks Error');
end;
end;

begin
writeln(getPageEx('https://render.githubusercontent.com'));
end.


Which prints everything just fine. The latest plugin does everything and it does it correctly. The include on the first page may be outdated which would explain the bug you're experiencing. I don't remember if I updated the include on the front page. I haven't had much time these days to even log in but if I'll try to update the front page.

rj
04-26-2015, 01:24 AM
Not sure what you're using or doing but if you use the latest plugin then you can do what the reflection include does as well:



{$loadlib prosocks}

Function GetPageEx(URL: String): String;
var
S: SSLSocket;
res: ProMemoryStruct;
begin
Pro_InitSocket(S, nil, nil, nil, nil);
Pro_CreateSocket(S, '');
Pro_SetSSL(S, false, false, true);
Pro_SetURL(S, URL);
Pro_DoGetEx(S, res);

{$IFDEF LAPE}
SetLength(Result, res.size);
MemMove(res.memory^, Result[1], res.size);
{$ELSE}
Result := res.memory;
{$ENDIF}


try
Pro_FreeSocket(S);
except
WriteLn('Unable to Free ' + URL + ' ProSocks Error');
end;
end;

begin
writeln(getPageEx('https://render.githubusercontent.com'));
end.


Which prints everything just fine. The latest plugin does everything and it does it correctly. The include on the first page may be outdated which would explain the bug you're experiencing. I don't remember if I updated the include on the front page. I haven't had much time these days to even log in but if I'll try to update the front page.

I'm getting

Error: Unknown declaration "ProMemoryStruct" at line 208 I put it in socks.simba is that a pascalscript version? I'm using lape

Brandon
04-26-2015, 02:16 AM
I'm getting

Error: Unknown declaration "ProMemoryStruct" at line 208 I put it in socks.simba is that a pascalscript version? I'm using lape


https://github.com/Brandon-T/ProSocks/releases/tag/v0.3 The above function is both Lape AND pascal script. Hence the "IFDEF".

rj
04-26-2015, 02:31 AM
https://github.com/Brandon-T/ProSocks/releases/tag/v0.3 The above function is both Lape AND pascal script. Hence the "IFDEF".

Which include do I use? My current one loads lib ProSock and the new one is Prosocks. Do I change the name or do I have an outdated include?

Brandon
04-26-2015, 03:30 AM
Which include do I use? My current one loads lib ProSock and the new one is Prosocks. Do I change the name or do I have an outdated include?


What exactly are you trying to do? Emails? Get requests? Posts? If it's just plain get requests and posts, you don't really need an include. The plugin is designed in such a way that an include isn't necessary. The email functions are built in and so is get and post. See: https://villavu.com/forum/showthread.php?t=108744&p=1314355#post1314355

The ability to use raw sockets is there but you don't have to go through the pain of that. There's only 3~4 steps you need:

Init
Create
//Do whatever you want (set flags, urls, headers, etc)
Free

rj
04-26-2015, 04:42 AM
What exactly are you trying to do? Emails? Get requests? Posts? If it's just plain get requests and posts, you don't really need an include. The plugin is designed in such a way that an include isn't necessary. The email functions are built in and so is get and post. See: https://villavu.com/forum/showthread.php?t=108744&p=1314355#post1314355

The ability to use raw sockets is there but you don't have to go through the pain of that. There's only 3~4 steps you need:

Init
Create
//Do whatever you want (set flags, urls, headers, etc)
Free

I'm trying to use getpage, I just pasted your above example and ported it into what I'm doing. After 2 file update I get this error


Unable to Free https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/core/globals.simba ProSocks Error

And the script just continues to run without outputting anymore debug (my script writes when it is updating a file)

//{$I Socks.Simba}
{$loadlib prosocks}


(*
Alotic include updater written by rj,
string functions by Janilabo, github page grabber by Brandon
*)

const
BASE_URL = 'https://raw.githubusercontent.com/officerBarbrady/Alotic/master/';
INCLUDE_PATH = 'C:\Simba\Includes\Alotic\';

type
TFileFormat = (FILE_PATH, WEB_PATH, DIRECTORY_PATH);

function mInc(var x: Integer; N: Integer = 1): Integer;
begin
Result := x;
x := (x + N);
end;

function mIncrease(var x: Integer; N: Integer = 1): Integer;
begin
x := (x + N);
Result := x;
end;

function mExplode(str: string; d: Char): TStringArray;
var
a, b, l, p, r, s: Integer;
begin
l := Length(str);
SetLength(Result, 1);
if (l > 0) then
begin
b := 1;
a := 1;
p := 0;
r := 0;
s := 0;
while (mInc(p) < l) do
if (str[p] = d) then
begin
Result[mInc(r)] := Copy(str, a, s);
if (b <= r) then
SetLength(Result, mIncrease(b, b));
a := (p + 1);
s := 0;
end else
s := (s + 1);
SetLength(Result, (r + 1));
Result[r] := Copy(str, a, s);
end else
Result[0] := str;
end;

function mLines(str: string): TStringArray;
begin
if (Length(str) = 0) then
begin
SetLength(Result, 1);
Result[0] := str;
end else
Result := mExplode(str, #10);
end;

function Before(s, str: string): string;
var
p: Integer;
begin
if (Length(s) < Length(str)) then
begin
p := Pos(s, str);
if (p > 1) then
Result := Copy(str, 1, (p - 1))
else
Result := '';
end else
Result := '';
end;

function formatPath(s:string;formatType:TFileFormat):string ;
var
base, fileType:string;
begin
case formatType of
FILE_PATH:
begin
fileType := between('[', ']', s);
base := before('[', s);
result := INCLUDE_PATH + base + '.' + fileType;
end;
WEB_PATH:
begin
s := replace(s, '\', '/', [rfReplaceall]);
fileType := between('[', ']', s);
base := before('[', s);
result := base + '.' + fileType;
end;
DIRECTORY_PATH:
begin
base := between('[', '\', s);
result := before(base, s);
end;
end;
end;

Function GetPageEx(URL: String): String;
var
S: SSLSocket;
res: ProMemoryStruct;
begin
Pro_InitSocket(S, nil, nil, nil, nil);
Pro_CreateSocket(S, '');
Pro_SetSSL(S, false, false, true);
Pro_SetURL(S, URL);
Pro_DoGetEx(S, res);

{$IFDEF LAPE}
SetLength(Result, res.size);
MemMove(res.memory^, Result[1], res.size);
{$ELSE}
Result := res.memory;
{$ENDIF}
try
Pro_FreeSocket(S);
except
WriteLn('Unable to Free ' + URL + ' ProSocks Error');
end;
end;



procedure updateInclude();
var
i, c, tmpFile:integer;
p:string;
filePaths:TStringArray;
fileContents:string;
begin
writeln('Scanning for files to update..');
p := getPageEx(BASE_URL + 'Files.txt');
if (p <> '') then
begin
if (formatPath(p, DIRECTORY_PATH) <> '') then
begin
if (not directoryExists(formatPath(p, DIRECTORY_PATH))) then
createDirectory(formatPath(p, DIRECTORY_PATH));
end;
filePaths := mLines(p);
for i := 0 to high(filePaths) do
begin
p := '';
p := getPageEx(BASE_URL + formatPath(filePaths[i], WEB_PATH));
try
tmpFile := openFile(formatPath(filePaths[i], FILE_PATH), false);
readFileString(tmpFile, fileContents, fileSize(tmpFile));
closeFile(tmpFile);
if (length(fileContents) <> length(p)) then
begin
tmpFile := reWriteFile(formatPath(filePaths[i], FILE_PATH), false);
if writeFileString(tmpFile, p) then
begin
c := c + 1;
writeln('Updated ', formatPath(filePaths[i], FILE_PATH));
end;
closeFile(tmpFile);
end;
except
try
writeln('Creating new File ', formatPath(filePaths[i], FILE_PATH));
tmpFile := createFile(formatPath(filePaths[i], FILE_PATH));
if (p <> '') then
begin
c := c + 1;
writeFileString(tmpFile, p);
end;
except
writeln('Failed to create File ', formatPath(filePaths[i], FILE_PATH));
finally
closeFile(tmpFile);
end;
end;
end;
writeln('Updated ' , c , ' Files');
end;
end;

begin
updateInclude();
end.

Brandon
04-26-2015, 01:39 PM
I'm trying to use getpage, I just pasted your above example and ported it into what I'm doing. After 2 file update I get this error



The only error I get when running your code is:


Compiled successfully in 406 ms.
Scanning for files to update..
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\Authors.txt
Creating new File C:\Simba\Includes\Alotic\Authors.txt
CreateFile - Exception. Could not create file: C:\Simba\Includes\Alotic\Authors.txt
Failed to create File C:\Simba\Includes\Alotic\Authors.txt
Error: Invalid FileNum passed: -1 at line 181
Execution failed.


And when I check the folder where the above script is located, it doesn't create a file called "Authors.txt". You're creating a FOLDER called "Authors[". In fact, it creates a folder: "C:/Simba/Scripts/Authors[" and "C:/Simba/Authors[".


When I debug your code, all the HTTP(S) calls work just fine (only file creation fails):

http://i.imgur.com/4rkutPf.png

rj
04-27-2015, 08:39 PM
...

Ok, I have the directory creation fixed (with the except of it creating blank files so it has to be run twice, whatever ill fix that later)but ProSocks is unable to free

Unable to Free https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/core/globals.simba ProSocks Error

After that, the script does nothing and has to be stopped. I figured I maybe the next webpage wasn't a valid webpage and that's why it's getting stuck but after further debugging found that not to be the case ( https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/core/mainscreen.simba exists)

It's always https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/core/globals.simba that it is unable to free for some odd reason

//{$I Socks.Simba}
{$loadlib prosocks}


(*
Alotic include updater written by rj,
string functions by Janilabo, github page grabber by Brandon
*)

const
BASE_URL = 'https://raw.githubusercontent.com/officerBarbrady/Alotic/master/';
INCLUDE_PATH = 'C:\Simba\Includes\Alotic\';

type
TFileFormat = (FILE_PATH, WEB_PATH, DIRECTORY_PATH);

function mInc(var x: Integer; N: Integer = 1): Integer;
begin
Result := x;
x := (x + N);
end;

function mIncrease(var x: Integer; N: Integer = 1): Integer;
begin
x := (x + N);
Result := x;
end;

function mExplode(str: string; d: Char): TStringArray;
var
a, b, l, p, r, s: Integer;
begin
l := Length(str);
SetLength(Result, 1);
if (l > 0) then
begin
b := 1;
a := 1;
p := 0;
r := 0;
s := 0;
while (mInc(p) < l) do
if (str[p] = d) then
begin
Result[mInc(r)] := Copy(str, a, s);
if (b <= r) then
SetLength(Result, mIncrease(b, b));
a := (p + 1);
s := 0;
end else
s := (s + 1);
SetLength(Result, (r + 1));
Result[r] := Copy(str, a, s);
end else
Result[0] := str;
end;

function mLines(str: string): TStringArray;
begin
if (Length(str) = 0) then
begin
SetLength(Result, 1);
Result[0] := str;
end else
Result := mExplode(str, #10);
end;

function Before(s, str: string): string;
var
p: Integer;
begin
if (Length(s) < Length(str)) then
begin
p := Pos(s, str);
if (p > 1) then
Result := Copy(str, 1, (p - 1))
else
Result := '';
end else
Result := '';
end;

function lastBefore(s, str: string): string;
var
l, p, lp: Integer;
begin
l := Length(str);
if (Length(s) <= l) then
begin
repeat
p := PosEx(s, str, (p + 1));
if (p > 0) then
lp := p;
until (p <= 0);
if (lp > 0) then
Result := Copy(str, 1, (lp - 1))
else
Result := '';
end else
Result := '';
end;

function formatPath(s:string;formatType:TFileFormat):string ;
var
base, fileType:string;
begin
case formatType of
FILE_PATH:
begin
fileType := between('[', ']', s);
base := before('[', s);
result := INCLUDE_PATH + base + '.' + fileType;
end;
WEB_PATH:
begin
s := replace(s, '\', '/', [rfReplaceall]);
fileType := between('[', ']', s);
base := before('[', s);
result := base + '.' + fileType;
end;
DIRECTORY_PATH:
begin
result := INCLUDE_PATH + lastBefore('\', s);
if (result[length(result)] <> '\') then
result := result + '\';
//writeln('result=',result);
end;
end;
end;

Function GetPageEx(URL: String): String;
var
S: SSLSocket;
res: ProMemoryStruct;
begin
Pro_InitSocket(S, nil, nil, nil, nil);
Pro_CreateSocket(S, '');
Pro_SetSSL(S, false, false, true);
Pro_SetURL(S, URL);
Pro_DoGetEx(S, res);

{$IFDEF LAPE}
SetLength(Result, res.size);
MemMove(res.memory^, Result[1], res.size);
{$ELSE}
Result := res.memory;
{$ENDIF}
try
Pro_FreeSocket(S);
except
WriteLn('Unable to Free ' + URL + ' ProSocks Error');
end;
end;



procedure updateInclude();
var
i, c, tmpFile:integer;
p:string;
filePaths:TStringArray;
fileContents:string;
begin
writeln('Scanning for files to update..');
p := getPageEx(BASE_URL + 'Files.txt');
//writeln(BASE_URL + 'Files.txt');
filePaths := mLines(p);
//writeln(filePaths);
for i := 0 to high(filePaths) do
begin
writeln('Webpath = ', BASE_URL + formatPath(filePaths[i], WEB_PATH));
//writeln('Path = ', formatPath(filePaths[i], DIRECTORY_PATH));
if (filePaths[i] <> '') then
begin
if (formatPath(filePaths[i], DIRECTORY_PATH) <> '') then
begin
if (not directoryExists(formatPath(filePaths[i], DIRECTORY_PATH))) then
begin
createDirectory(formatPath(filePaths[i], DIRECTORY_PATH));
//wait(1000);
end;
end;
p := '';
p := getPageEx(BASE_URL + formatPath(filePaths[i], WEB_PATH));
try
tmpFile := openFile(formatPath(filePaths[i], FILE_PATH), false);
readFileString(tmpFile, fileContents, fileSize(tmpFile));
closeFile(tmpFile);
if (length(fileContents) <> length(p)) then
begin
tmpFile := reWriteFile(formatPath(filePaths[i], FILE_PATH), false);
if writeFileString(tmpFile, p) then
begin
c := c + 1;
writeln('Updated ', formatPath(filePaths[i], FILE_PATH));
end;
closeFile(tmpFile);
end;
except
try
writeln('Creating new File ', formatPath(filePaths[i], FILE_PATH));
tmpFile := createFile(formatPath(filePaths[i], FILE_PATH));
if (p <> '') then
begin
c := c + 1;
writeFileString(tmpFile, p);
end;
except
// writeln('Failed to create File ', formatPath(filePaths[i], FILE_PATH));
finally
if (tmpFile <> -1) then
closeFile(tmpFile);
end;
end;
end;
end;
writeln('Updated ' , c , ' Files');
end;

begin
updateInclude();
end.

Brandon
04-27-2015, 11:29 PM
...


Try this (a direct link to the plugin on github): https://github.com/Brandon-T/ProSocks/releases/download/v0.3/ProSocks.dll

I have a feeling you're somehow using a very OLD version of the plugin. The above is the latest build and that's the one myself & the reflection include uses.


When I run your code I get:


Compiled successfully in 422 ms.
Scanning for files to update..
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/Authors.txt
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\Authors.txt
Creating new File C:\Simba\Includes\Alotic\Authors.txt
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/Files.txt
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\Files.txt
Creating new File C:\Simba\Includes\Alotic\Files.txt
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/Alotic.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\Alotic.simba
Creating new File C:\Simba\Includes\Alotic\lib\Alotic.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/Updater.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\Updater.simba
Creating new File C:\Simba\Includes\Alotic\lib\Updater.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/core/globals.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\core\globals.simba
Creating new File C:\Simba\Includes\Alotic\lib\core\globals.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/core/mainscreen.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\core\mainscreen.simba
Creating new File C:\Simba\Includes\Alotic\lib\core\mainscreen.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/core/math.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\core\math.simba
Creating new File C:\Simba\Includes\Alotic\lib\core\math.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/core/mouse.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\core\mouse.simba
Creating new File C:\Simba\Includes\Alotic\lib\core\mouse.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/core/prayer.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\core\prayer.simba
Creating new File C:\Simba\Includes\Alotic\lib\core\prayer.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/core/text.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\core\text.simba
Creating new File C:\Simba\Includes\Alotic\lib\core\text.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/interfaces/bank.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\interfaces\bank.simba
Creating new File C:\Simba\Includes\Alotic\lib\interfaces\bank.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/interfaces/chatbox.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\interfaces\chatbox.si mba
Creating new File C:\Simba\Includes\Alotic\lib\interfaces\chatbox.si mba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/interfaces/gametab.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\interfaces\gametab.si mba
Creating new File C:\Simba\Includes\Alotic\lib\interfaces\gametab.si mba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/interfaces/interface.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\interfaces\interface. simba
Creating new File C:\Simba\Includes\Alotic\lib\interfaces\interface. simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/interfaces/inventory.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\interfaces\inventory. simba
Creating new File C:\Simba\Includes\Alotic\lib\interfaces\inventory. simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/interfaces/minimap.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\interfaces\minimap.si mba
Creating new File C:\Simba\Includes\Alotic\lib\interfaces\minimap.si mba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/misc/Simba.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\misc\Simba.simba
Creating new File C:\Simba\Includes\Alotic\lib\misc\Simba.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/misc/datatypes/extendedarrays.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\misc\datatypes\extend edarrays.simba
Creating new File C:\Simba\Includes\Alotic\lib\misc\datatypes\extend edarrays.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/misc/datatypes/integer.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\misc\datatypes\intege r.simba
Creating new File C:\Simba\Includes\Alotic\lib\misc\datatypes\intege r.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/misc/datatypes/integerarrays.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\misc\datatypes\intege rarrays.simba
Creating new File C:\Simba\Includes\Alotic\lib\misc\datatypes\intege rarrays.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/misc/datatypes/string.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\misc\datatypes\string .simba
Creating new File C:\Simba\Includes\Alotic\lib\misc\datatypes\string .simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/misc/datatypes/stringarrays.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\misc\datatypes\string arrays.simba
Creating new File C:\Simba\Includes\Alotic\lib\misc\datatypes\string arrays.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/misc/datatypes/t2dstringarray.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\misc\datatypes\t2dstr ingarray.simba
Creating new File C:\Simba\Includes\Alotic\lib\misc\datatypes\t2dstr ingarray.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/misc/datatypes/tbox.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\misc\datatypes\tbox.s imba
Creating new File C:\Simba\Includes\Alotic\lib\misc\datatypes\tbox.s imba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/misc/datatypes/tpoint.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\misc\datatypes\tpoint .simba
Creating new File C:\Simba\Includes\Alotic\lib\misc\datatypes\tpoint .simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/misc/datatypes/tpointarrays.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\misc\datatypes\tpoint arrays.simba
Creating new File C:\Simba\Includes\Alotic\lib\misc\datatypes\tpoint arrays.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/misc/datatypes/typemath.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\misc\datatypes\typema th.simba
Creating new File C:\Simba\Includes\Alotic\lib\misc\datatypes\typema th.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/misc/datatypes/types.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\misc\datatypes\types. simba
Creating new File C:\Simba\Includes\Alotic\lib\misc\datatypes\types. simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/player/login.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\player\login.simba
Creating new File C:\Simba\Includes\Alotic\lib\player\login.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/player/player.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\player\player.simba
Creating new File C:\Simba\Includes\Alotic\lib\player\player.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/player/varManager.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\player\varManager.sim ba
Creating new File C:\Simba\Includes\Alotic\lib\player\varManager.sim ba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/utilities/canvas.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\utilities\canvas.simb a
Creating new File C:\Simba\Includes\Alotic\lib\utilities\canvas.simb a
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/utilities/color.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\utilities\color.simba
Creating new File C:\Simba\Includes\Alotic\lib\utilities\color.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/utilities/debug.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\utilities\debug.simba
Creating new File C:\Simba\Includes\Alotic\lib\utilities\debug.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/utilities/debugBox.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\utilities\debugBox.si mba
Creating new File C:\Simba\Includes\Alotic\lib\utilities\debugBox.si mba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/utilities/drawing.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\utilities\drawing.sim ba
Creating new File C:\Simba\Includes\Alotic\lib\utilities\drawing.sim ba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/utilities/file.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\utilities\file.simba
Creating new File C:\Simba\Includes\Alotic\lib\utilities\file.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/utilities/timing.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\utilities\timing.simb a
Creating new File C:\Simba\Includes\Alotic\lib\utilities\timing.simb a
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/utilities/wrappers.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\utilities\wrappers.si mba
Creating new File C:\Simba\Includes\Alotic\lib\utilities\wrappers.si mba
Updated 37 Files
Successfully executed.



and everything gets created and downloaded fine.. Do some error checking in "GetPageEx" make sure res.size > 0. Other than that, there's nothing wrong :S

rj
04-27-2015, 11:43 PM
Try this (a direct link to the plugin on github): https://github.com/Brandon-T/ProSocks/releases/download/v0.3/ProSocks.dll

I have a feeling you're somehow using a very OLD version of the plugin. The above is the latest build and that's the one myself & the reflection include uses.


When I run your code I get:


Compiled successfully in 422 ms.
Scanning for files to update..
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/Authors.txt
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\Authors.txt
Creating new File C:\Simba\Includes\Alotic\Authors.txt
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/Files.txt
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\Files.txt
Creating new File C:\Simba\Includes\Alotic\Files.txt
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/Alotic.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\Alotic.simba
Creating new File C:\Simba\Includes\Alotic\lib\Alotic.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/Updater.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\Updater.simba
Creating new File C:\Simba\Includes\Alotic\lib\Updater.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/core/globals.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\core\globals.simba
Creating new File C:\Simba\Includes\Alotic\lib\core\globals.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/core/mainscreen.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\core\mainscreen.simba
Creating new File C:\Simba\Includes\Alotic\lib\core\mainscreen.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/core/math.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\core\math.simba
Creating new File C:\Simba\Includes\Alotic\lib\core\math.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/core/mouse.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\core\mouse.simba
Creating new File C:\Simba\Includes\Alotic\lib\core\mouse.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/core/prayer.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\core\prayer.simba
Creating new File C:\Simba\Includes\Alotic\lib\core\prayer.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/core/text.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\core\text.simba
Creating new File C:\Simba\Includes\Alotic\lib\core\text.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/interfaces/bank.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\interfaces\bank.simba
Creating new File C:\Simba\Includes\Alotic\lib\interfaces\bank.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/interfaces/chatbox.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\interfaces\chatbox.si mba
Creating new File C:\Simba\Includes\Alotic\lib\interfaces\chatbox.si mba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/interfaces/gametab.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\interfaces\gametab.si mba
Creating new File C:\Simba\Includes\Alotic\lib\interfaces\gametab.si mba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/interfaces/interface.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\interfaces\interface. simba
Creating new File C:\Simba\Includes\Alotic\lib\interfaces\interface. simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/interfaces/inventory.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\interfaces\inventory. simba
Creating new File C:\Simba\Includes\Alotic\lib\interfaces\inventory. simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/interfaces/minimap.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\interfaces\minimap.si mba
Creating new File C:\Simba\Includes\Alotic\lib\interfaces\minimap.si mba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/misc/Simba.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\misc\Simba.simba
Creating new File C:\Simba\Includes\Alotic\lib\misc\Simba.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/misc/datatypes/extendedarrays.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\misc\datatypes\extend edarrays.simba
Creating new File C:\Simba\Includes\Alotic\lib\misc\datatypes\extend edarrays.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/misc/datatypes/integer.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\misc\datatypes\intege r.simba
Creating new File C:\Simba\Includes\Alotic\lib\misc\datatypes\intege r.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/misc/datatypes/integerarrays.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\misc\datatypes\intege rarrays.simba
Creating new File C:\Simba\Includes\Alotic\lib\misc\datatypes\intege rarrays.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/misc/datatypes/string.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\misc\datatypes\string .simba
Creating new File C:\Simba\Includes\Alotic\lib\misc\datatypes\string .simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/misc/datatypes/stringarrays.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\misc\datatypes\string arrays.simba
Creating new File C:\Simba\Includes\Alotic\lib\misc\datatypes\string arrays.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/misc/datatypes/t2dstringarray.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\misc\datatypes\t2dstr ingarray.simba
Creating new File C:\Simba\Includes\Alotic\lib\misc\datatypes\t2dstr ingarray.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/misc/datatypes/tbox.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\misc\datatypes\tbox.s imba
Creating new File C:\Simba\Includes\Alotic\lib\misc\datatypes\tbox.s imba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/misc/datatypes/tpoint.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\misc\datatypes\tpoint .simba
Creating new File C:\Simba\Includes\Alotic\lib\misc\datatypes\tpoint .simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/misc/datatypes/tpointarrays.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\misc\datatypes\tpoint arrays.simba
Creating new File C:\Simba\Includes\Alotic\lib\misc\datatypes\tpoint arrays.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/misc/datatypes/typemath.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\misc\datatypes\typema th.simba
Creating new File C:\Simba\Includes\Alotic\lib\misc\datatypes\typema th.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/misc/datatypes/types.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\misc\datatypes\types. simba
Creating new File C:\Simba\Includes\Alotic\lib\misc\datatypes\types. simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/player/login.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\player\login.simba
Creating new File C:\Simba\Includes\Alotic\lib\player\login.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/player/player.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\player\player.simba
Creating new File C:\Simba\Includes\Alotic\lib\player\player.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/player/varManager.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\player\varManager.sim ba
Creating new File C:\Simba\Includes\Alotic\lib\player\varManager.sim ba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/utilities/canvas.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\utilities\canvas.simb a
Creating new File C:\Simba\Includes\Alotic\lib\utilities\canvas.simb a
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/utilities/color.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\utilities\color.simba
Creating new File C:\Simba\Includes\Alotic\lib\utilities\color.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/utilities/debug.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\utilities\debug.simba
Creating new File C:\Simba\Includes\Alotic\lib\utilities\debug.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/utilities/debugBox.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\utilities\debugBox.si mba
Creating new File C:\Simba\Includes\Alotic\lib\utilities\debugBox.si mba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/utilities/drawing.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\utilities\drawing.sim ba
Creating new File C:\Simba\Includes\Alotic\lib\utilities\drawing.sim ba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/utilities/file.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\utilities\file.simba
Creating new File C:\Simba\Includes\Alotic\lib\utilities\file.simba
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/utilities/timing.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\utilities\timing.simb a
Creating new File C:\Simba\Includes\Alotic\lib\utilities\timing.simb a
Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/utilities/wrappers.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\utilities\wrappers.si mba
Creating new File C:\Simba\Includes\Alotic\lib\utilities\wrappers.si mba
Updated 37 Files
Successfully executed.



and everything gets created and downloaded fine.. Do some error checking in "GetPageEx" make sure res.size > 0. Other than that, there's nothing wrong :S

Ahh there we go, yes!

Any idea why it creates blank file but doesn't fill them? Could it be because I'm creating the file and it's trying to write to the file before it's created? (there is that like 2-3 second delay before it's created)

Brandon
04-28-2015, 01:28 AM
Ahh there we go, yes!

Any idea why it creates blank file but doesn't fill them? Could it be because I'm creating the file and it's trying to write to the file before it's created? (there is that like 2-3 second delay before it's created)


You're not actually writing anything to the file in the first place.

Consider the following sequence:


Webpath = https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/utilities/wrappers.simba
OpenFile - Exception. Could not open file: C:\Simba\Includes\Alotic\lib\utilities\wrappers.si mba
Creating new File C:\Simba\Includes\Alotic\lib\utilities\wrappers.si mba


Notice the highlighted line. "Exception". When the exception occurs, you've triggered a try-catch block. It automatically jumps straight to the catch block and tries to create the non-existent file but the exception is an internal exception and not one that you can easily handle unless you know the state that the file handle is in after failure or upon the occurrence of the exception.


This is the reason for "fileExists" instead of trying to catch the exception. You should be using something like:


if (not fileExists(........)) then
tmpFile := createFile(.........)
else
tmpFile := openFile(.........);


to test the existence of the file INSTEAD of:


try
tmpFile := openFile(......);
except
tmpFile := createFile(......);
end


You may not be able to continue after the exception is thrown. The internals may be in an invalid state. I (me) don't have any idea of any the integrity of Simba's internals upon the above exception. You can ask one of the Simba devs about the state of Simba after an internal exception.

BUT your code works if you do what I said above instead of catching the exception. In other languages you can test if a file exists by trying to open it or to read its attributes. That doesn't seem to be the case in Simba.


P.S. The exception block in programming, isn't for "getting around an exception 100% of the time" (always ignoring it). It's for "handling the exception in a safe manner". You are mis-using it a bit. Slight but subtle difference. There are cases you can ignore an exception and cases where you cannot.

Example: Instead of try-catching a null pointer exception and trying to continue execution of some code.. You should be testing for null before using your pointers. This is just an example.

Test if the file is open first instead of trying to catch the exception and continue execution of some code. Ask a Simba dev for more information on the state of the internals upon an internal Simba exception.

Clarity
04-28-2015, 01:37 AM
{$loadlib ProSocks}


Loading extension C:\Simba\Extensions\companion.sex
Error in Simba extension compilation (C:\Simba\Extensions\companion.sex) : Unknown compiler directives at 6:3


I've been told Simba extensions do not support plugins, is there some other way to go about implementing ProSocks within an extension? This one (https://villavu.com/forum/showthread.php?t=112605), specifically, as I'd like to implement some in-depth forum features via simulating Villavu logins.

http://i.gyazo.com/ce8066ddcf0caa7cf1955e9eefcb3e88.png

rj
04-28-2015, 01:50 AM
...

Thanks got it. Also found out that you must 'rewrite' the file before writing to it, explains part of the reason the files were blank (after I fixed the try/except)

Brandon
04-28-2015, 04:34 AM
...

Unless you know how to turn integers to function pointers in pascal script, it won't be possible unless I add functions to the plugin that does that for us..


type ProWritePtr = Function(contents: PChar; size: PtrUInt; nmemb: PtrUint; var userp: String): PtrUInt;
type ProErrorHandlerPtr = Function(str: PChar; errorcode: LongInt): PtrUInt;
type ProLenPtr = Function(var Str: String): PtrUInt;


type
ProMemoryStruct = record
memory: PChar;
size: PtrUInt;
end;

type
SSLSocket = record
curl_handle: PtrUInt;
headers: PChar;
data: PChar;
params: PChar;
LengthFunc: ProLenPtr;
ErrorHandlerFunc: ProErrorHandlerPtr;
WriteFunc: ProWritePtr;
HeaderFunc: ProWritePtr;
hdrs: PChar;
Timeout: Cardinal;
Port: Word;
caller_allocates: Boolean;
end;

type
TPro_InitSocket = Procedure(var curl_info: SSLSocket; WriteFunc: ProWritePtr; HeaderFunc: ProWritePtr; ErrorHandlerFunc: ProErrorHandlerPtr; StrLenFunc: ProLenPtr);
TPro_CreateSocket = Procedure(var curl_info: SSLSocket; useragent: String);
TPro_FreeSocket = Procedure(var curl_info: SSLSocket);
TPro_SetSSL = Procedure(var curl_info: SSLSocket; try_set: Boolean; verifypeer: Boolean; verifyhost: Boolean);
TPro_SetURL = Procedure(var curl_info: SSLSocket; const URL: String);
TPro_DoGetEx = Procedure(var curl_info: SSLSocket; var Res: ProMemoryStruct);
TPro_PerformEx = Procedure(var curl_info: SSLSocket; var Res: ProMemoryStruct);


function LoadModule(ModulePath: PChar): LongInt; external 'LoadLibraryA@Kernel32.dll stdcall';
function FreeModule(Module: LongInt): Boolean; external 'FreeLibrary@Kernel32.dll stdcall';

function Get_ProInitSocket(Module: LongInt; Name: PChar): TPro_InitSocket; external 'GetProcAddress@Kernel32.dll stdcall';
function Get_ProCreateSocket(Module: LongInt; Name: PChar): TPro_CreateSocket; external 'GetProcAddress@Kernel32.dll stdcall';
function Get_ProFreeSocket(Module: LongInt; Name: PChar): TPro_FreeSocket; external 'GetProcAddress@Kernel32.dll stdcall';
function Get_ProSetSSL(Module: LongInt; Name: PChar): TPro_SetSSL; external 'GetProcAddress@Kernel32.dll stdcall';
function Get_ProSetURL(Module: LongInt; Name: PChar): TPro_SetURL; external 'GetProcAddress@Kernel32.dll stdcall';
function Get_ProDoGetEx(Module: LongInt; Name: PChar): TPro_DoGetEx; external 'GetProcAddress@Kernel32.dll stdcall';
function Get_ProPerformEx(Module: LongInt; Name: PChar): TPro_PerformEx; external 'GetProcAddress@Kernel32.dll stdcall';


function GetProcAddress(Module: LongInt; Name: PChar): LongInt; external 'GetProcAddress@Kernel32.dll stdcall';


var
Prosocks: LongInt;
Pro_InitSocket: TPro_InitSocket;
Pro_CreateSocket: TPro_CreateSocket;
Pro_FreeSocket: TPro_FreeSocket;
Pro_SetSSL: TPro_SetSSL;
Pro_SetURL: TPro_SetURL;
Pro_DoGetEx: TPro_DoGetEx;
Pro_PerformEx: TPro_PerformEx;




Function GetPageEx(URL: String): String;
var
S: SSLSocket;
res: ProMemoryStruct;
begin
Pro_InitSocket(S, nil, nil, nil, nil);
Pro_CreateSocket(S, '');
Pro_SetSSL(S, false, false, true);
Pro_SetURL(S, URL);
Pro_DoGetEx(S, res);

{$IFDEF LAPE}
SetLength(Result, res.size);
MemMove(res.memory^, Result[1], res.size);
{$ELSE}
Result := res.memory;
{$ENDIF}


try
Pro_FreeSocket(S);
except
WriteLn('Unable to Free ' + URL + ' ProSocks Error');
end;
end;


function GetName : string;
begin;
result := 'My Extension';
end;

function GetVersion : string;
begin;
result := '0.1';
end;

procedure Free;
begin

end;

procedure Attach;
begin
writeln(' ~Loaded~ ');
ProSocks := LoadModule('C:/Simba/Plugins/ProSocks.dll');

writeln('Prosocks Address: ' + ToStr(ProSocks));
writeln('ProcAddress using LongInt: ' + ToStr(GetProcAddress(ProSocks, 'Curl_InitSocket')));
writeln('ProcAddress using Type: ' + ToStr(Get_ProInitSocket(ProSocks, 'Curl_InitSocket')));

Pro_InitSocket := Get_ProInitSocket(ProSocks, 'Curl_InitSocket');
Pro_CreateSocket := Get_ProCreateSocket(ProSocks, 'Curl_CreateSocket');
Pro_FreeSocket := Get_ProFreeSocket(ProSocks, 'Curl_FreeSocket');
Pro_SetSSL := Get_ProSetSSL(ProSocks, 'Curl_SetSSL');
Pro_SetURL := Get_ProSetURL(ProSocks, 'Curl_SetURL');
Pro_DoGetEx := Get_ProDoGetEx(ProSocks, 'Curl_DoGetEx');
Pro_PerformEx := Get_ProPerformEx(ProSocks, 'Curl_PerformEx');

//writeln(GetPageEx('https://raw.githubusercontent.com/officerBarbrady/Alotic/master/lib/core/globals.simba'));
end;

Procedure Detach;
begin
Writeln('~Unloaded~');
FreeModule(ProSocks);
end;


Begin
End.



Output:


Loading extension C:\Simba\Extensions\Test.sex
Extension Enabled

~Loaded~

Prosocks Address: 1868300288
ProcAddress using LongInt: 1868306240
ProcAddress using Type: Proc: 0 //should not be nil or 0.


Not sure why it's nil or 0 tbh..

Clarity
04-28-2015, 05:33 AM
...
Okay, thanks for the reply! I'm very interested in adding this functionality so I'll see what I can learn. Especially regarding the LoadModule/related functions, I would have had no idea how to do something like that.

Brandon
04-28-2015, 01:20 PM
Okay, thanks for the reply! I'm very interested in adding this functionality so I'll see what I can learn. Especially regarding the LoadModule/related functions, I would have had no idea how to do something like that.

https://villavu.com/forum/showthread.php?t=65657

If I cannot figure out why it doesn't work for the extension I posted in the previous post and somehow it works for the above extension in that link, then I will modify the plugin and test if the functions are being called and modify to suit.

It is odd that it doesn't work in my previous post (unless the return type is longInt) :l

Olly
04-28-2015, 03:03 PM
https://villavu.com/forum/showthread.php?t=65657

If I cannot figure out why it doesn't work for the extension I posted in the previous post and somehow it works for the above extension in that link, then I will modify the plugin and test if the functions are being called and modify to suit.

It is odd that it doesn't work in my previous post (unless the return type is longInt) :l

All method importing & calling has to be put through pascal script first, you cant just import something via GetProcAddress and expect work fully.

Could also be wrong, but i'm quite sure.

Brandon
04-29-2015, 12:10 AM
All method importing & calling has to be put through pascal script first, you cant just import something via GetProcAddress and expect work fully.

Could also be wrong, but i'm quite sure.


Consider:


someLongInt := GetProcAddress(module, 'funcName');


That works but:


someFunctionPointer := GetProcAddress(module, 'funcName');


does not. So it's not the importing that is failing. It's the assignment operator that fails. In fact, I didn't even begin to call the function via the function pointer. I printed just the address of it which turns out to be NULL but the longInt has a valid address.

Can always pass the func ptr to the plugin and have the plugin give it an address. That would work.

Clarity
04-29-2015, 01:06 AM
Brandon, you're a legend! I spent a few hours trying to make things work but to no avail. I'll keep checking this thread for more updates.

Paradoxs
10-11-2015, 05:14 PM
Does the HTTPS object have a do post command? I myself can't seem to find it nor could I figure out a definitive way of testing if it did it passively, though my guess is that it does not. Would it be simpler for me to adapt your facebook login example using the socket object to accomplish a post request

Brandon
10-11-2015, 08:18 PM
Does the HTTPS object have a do post command? I myself can't seem to find it nor could I figure out a definitive way of testing if it did it passively, though my guess is that it does not. Would it be simpler for me to adapt your facebook login example using the socket object to accomplish a post request

It has a doPost and doPostEx (use this one) function. https://github.com/Brandon-T/ProSocks/blob/master/LanguageExports.h#L75

I was just working on updating the library a few mins ago. Got it working for OSX too http://i.imgur.com/d0Oshvv.png :D

Paradoxs
10-11-2015, 08:38 PM
It does have a doPost and doPostEx function. https://github.com/Brandon-T/ProSocks/blob/master/LanguageExports.h#L75

I actually realized the stupidity of my question as soon as I asked, my main problem was the same as RJ's, I was messing with the socks.simba function included at the top, which uses prosock.dll, the newer versions of the dll are prosocks.dll

The https type that the socks.simba has does not have a dopost, but it wasn't needed, since I just went ahead and made my own functions with a custom type, using the new DLL was much much more simple and reading through the socks.simba and figuring out how each part worked in that fashion.

Correct me if I'm wrong about the socks.simba using an old version part. Might want to update the main post as well, because it really does seem to point to an older version
http://s21.postimg.org/ki27i4f8n/Untitled.png

and socks.simba needs to be updated to use this newer version as attempting to run it with the newer versions causes failures. This is due to the fact that v.02 introduced the easier to use api (at least that's my assumption)

using prosocks.dll (v 0.3)

Error: Unknown declaration "Pro_ReadSocket" at line 75
Compiling failed.

using prodock.dll from main post(Assuming it's v 0.1)

Compiled successfully in 578 ms.
Successfully executed.

Also just noticed v0.4, greedily awaiting the windows release ;)

Brandon
10-11-2015, 08:46 PM
...


Yeah anything after v0.1 does NOT use an include. The main post is outdated. Sorry for the confusion. I'll have to update it. Yeah I didn't compile Windows v0.4 version yet because my Windows laptop broke ={. Didn't wanna install a VM. I'll upload a Windows & Linux build when I get a chance but v0.3 works just as well.


Don't worry about using Socks.simba or any includes. All you need is the plugin. No other files.

Paradoxs
10-11-2015, 08:48 PM
Yeah anything after v0.1 does NOT use an include. The main post is outdated. I'll have to update it. Yeah I didn't compile Windows v0.4 version yet because my Windows laptop broke ={ LOL. Didn't wanna install a VM. I'll upload a Windows build when I get a chance but v0.3 works just as well.


Don't worry about using Socks.simba or any includes. All you need is the plugin. No other files.

Oh I know, I just meant that without going through the entire thread a new user of proSocks won't know that, I figure the getpostEx function you posted + an updated download to v0.3 will be enough to replace the current sample and incorrect dll

Brandon
10-11-2015, 09:20 PM
Oh I know, I just meant that without going through the entire thread a new user of proSocks won't know that, I figure the getpostEx function you posted + an updated download to v0.3 will be enough to replace the current sample and incorrect dll

Updated the OP. Everything should be good now. No more confusing posts or having to go through the thread to figure things out.

Paradoxs
10-11-2015, 09:44 PM
Appreciate it man!

Love the plugin, thanks for taking the time to develop it (and the easy to use API)

Edit:

Actually @Brandon In v0.3 Pro_SetParameter causeses an access violation, when downgrading to v0.2 the problem is resolved, when I have time if you haven't already been aware of the issue I'll look and see if I can figure out what exactly is causing it.

Brandon
10-12-2015, 01:37 AM
Appreciate it man!

Love the plugin, thanks for taking the time to develop it (and the easy to use API)

Edit:

Actually @Brandon In v0.3 Pro_SetParameter causeses an access violation, when downgrading to v0.2 the problem is resolved, when I have time if you haven't already been aware of the issue I'll look and see if I can figure out what exactly is causing it.



What is the code you're using to POST? I just tested this:


ProSock sock = {0};
Pro_InitSocket(&sock, nullptr, nullptr, nullptr, nullptr);
Pro_CreateSocket(&sock, "");
Pro_SetVerbose(&sock, false);
Pro_SetSSL(&sock, false, false, true);
Pro_SetHeader(&sock, "Content-Type", "text/plain");
Pro_AddParameter(&sock, "Key1", "Value1", false);
Pro_AddParameter(&sock, "Key2", "Value2", true);

Pro_SetURL(&sock, "http://posttestserver.com/post.php?dump");
//Pro_SetURL(&sock, "http://httpbin.org/post?testArgs=1024");

ProMemoryStruct mem = {0};
Pro_DoPostEx(&sock, &mem);

std::cout.write(mem.memory, mem.size);
std::cout<<"\n\n"<<std::endl;

Curl_FreeSocket(&sock);


Result:


Time: Sun, 11 Oct 15 18:32:28 -0700
Source ip: XX.XX.XXX.XXX

Headers (Some may be inserted by server)
HTTP_CONNECTION = close
REQUEST_URI = /post.php?dump
QUERY_STRING = dump
REQUEST_METHOD = POST
GATEWAY_INTERFACE = CGI/1.1
REMOTE_PORT = 63111
REMOTE_ADDR = XX.XX.XXX.XXX
CONTENT_LENGTH = 23
CONTENT_TYPE = text/plain
HTTP_ACCEPT = */*
HTTP_USER_AGENT = Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36
HTTP_HOST = posttestserver.com
UNIQUE_ID = VhsNrNBx6hIAAH1WJScAAAAB
REQUEST_TIME_FLOAT = 1444613548.1021
REQUEST_TIME = 1444613548

No Post Params.

== Begin post body ==
Key1=Value1&Key2=Value2
== End post body ==

Upload contains PUT data:
Key1=Value1&Key2=Value2


Program ended with exit code: 0




{
"args": {
"testArgs": "1024"
},
"data": "Key1=Value1&Key2=Value2",
"files": {},
"form": {},
"headers": {
"Accept": "*/*",
"Content-Length": "23",
"Content-Type": "text/plain",
"Host": "httpbin.org",
"User-Agent": "Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36"
},
"json": null,
"origin": "XX.XX.XXX.XXX",
"url": "http://httpbin.org/post?testArgs=1024"
}



Program ended with exit code: 0

Paradoxs
10-12-2015, 01:57 AM
I was using the example, and my own code based off the example and the first Pro_AddParemeter led to an access violation. Could it be that I'm not setting the verbose? (In simba just to clarify, lape interpreter, the pascal interpreter fails too but I don't remember where)

riwu
12-15-2015, 11:50 AM
...
Brandon;

How do i use ./configure on windows?
When i tried to execute it on openssl source it gave this error:
http://i.imgur.com/WGY3tcw.png

When i did it on the prosocks source:
http://i.imgur.com/h29Mk15.png


https://github.com/riwu/ProSocks/blob/master/LanguageExports.h#L53
How do u specify these directives in lazarus FPC?
i tried doing {$DEFINE PASCALSCRIPT} it still imported those procedures from L83 (i used Dynlibs.LoadLibrary(), followed by GetProcAddress(libHandle, 'GetFunctionInfo') to retrieve the proc address)

Brandon
12-16-2015, 01:44 AM
Brandon;

How do i use ./configure on windows?
When i tried to execute it on openssl source it gave this error:
http://i.imgur.com/WGY3tcw.png

When i did it on the prosocks source:
http://i.imgur.com/h29Mk15.png


https://github.com/riwu/ProSocks/blob/master/LanguageExports.h#L53
How do u specify these directives in lazarus FPC?
i tried doing {$DEFINE PASCALSCRIPT} it still imported those procedures from L83 (i used Dynlibs.LoadLibrary(), followed by GetProcAddress(libHandle, 'GetFunctionInfo') to retrieve the proc address)



It says you don't have perl installed. Why are you configuring prosocks though? You need to configure curl and openssl and just compile prosocks as normal.

As for preprocessor arguments, I'm not sure about Lazarus FPC but I know via command line it's -DPASCAL_SCRIPT. Are you building for PascalScript?

Kyle Undefined
12-16-2015, 01:49 AM
Wow, this is fantastic. Great work on this man, would have made the old days so much easier ha.

riwu
12-16-2015, 03:28 PM
It says you don't have perl installed. Why are you configuring prosocks though? You need to configure curl and openssl and just compile prosocks as normal.

As for preprocessor arguments, I'm not sure about Lazarus FPC but I know via command line it's -DPASCAL_SCRIPT. Are you building for PascalScript?
I figured out how to correctly import the dll from FPC, still want to learn how to compile the plugin though.
I installed ActivePerl and managed to install ZLIB and OpenSSL, but having problem at LIBCURL:
http://pastebin.com/raw/61GWJ3Pf (entire log from config to make install)
Last few lines of make install:


c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/bin/ld.exe: curl-tool_cb_dbg.o: bad reloc address 0xec in section `.rdata'
collect2.exe: error: ld returned 1 exit status
make[2]: *** [curl.exe] Error 1
make[2]: Leaving directory `/c/Users/1/Desktop/curl-7.45.0/src'
make[1]: *** [install] Error 2
make[1]: Leaving directory `/c/Users/1/Desktop/curl-7.45.0/src'
make: *** [install-recursive] Error 1


I googled for some solution, none of them works for me. One of the solution is:


make SYS=mingw CRYPTO=POLARSSL \
CPATH=/mingw/include LIBRARY_PATH=/mingw/lib SHARED= XLDFLAGS=-static

Brandon
12-17-2015, 02:30 AM
I figured out how to correctly import the dll from FPC, still want to learn how to compile the plugin though.
I installed ActivePerl and managed to install ZLIB and OpenSSL, but having problem at LIBCURL:
http://pastebin.com/raw/61GWJ3Pf (entire log from config to make install)
Last few lines of make install:


c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/bin/ld.exe: curl-tool_cb_dbg.o: bad reloc address 0xec in section `.rdata'
collect2.exe: error: ld returned 1 exit status
make[2]: *** [curl.exe] Error 1
make[2]: Leaving directory `/c/Users/1/Desktop/curl-7.45.0/src'
make[1]: *** [install] Error 2
make[1]: Leaving directory `/c/Users/1/Desktop/curl-7.45.0/src'
make: *** [install-recursive] Error 1


I googled for some solution, none of them works for me. One of the solution is:


make SYS=mingw CRYPTO=POLARSSL \
CPATH=/mingw/include LIBRARY_PATH=/mingw/lib SHARED= XLDFLAGS=-static


.rdata is relocation section in assembly assembly (linker/import section).

The log says you are trying to link 32-bit libraries with 64-bit ones. Make sure that everything you are building is using the same architecture. That is why I explicitly configured with: --build=i686-pc-windows "CFLAGS=-m32" "CXXFLAGS=-m32" "LDFLAGS=-m32" for 32-bit and --build=x86_64-w64-mingw32 "CFLAGS=-m64" "CXXFLAGS=-m64" "LDFLAGS=-m64" for 64bit.

I can provide step by step instructions it still doesn't work.

riwu
12-17-2015, 09:42 AM
.rdata is relocation section in assembly assembly (linker/import section).

The log says you are trying to link 32-bit libraries with 64-bit ones. Make sure that everything you are building is using the same architecture. That is why I explicitly configured with: --build=i686-pc-windows "CFLAGS=-m32" "CXXFLAGS=-m32" "LDFLAGS=-m32" for 32-bit and --build=x86_64-w64-mingw32 "CFLAGS=-m64" "CXXFLAGS=-m64" "LDFLAGS=-m64" for 64bit.

I can provide step by step instructions it still doesn't work.
When i tried to install 32-bit openssl it said:

cryptlib.c:1:0: error: CPU you selected does not support x86-64 instruction set
Full log: http://pastebin.com/raw/KE3itAX6
So i installed 64bit version of it instead.

Also i had to remove --no-shared because it gave this error:

gcc.exe: error: unrecognized command line option '--no-shared'
The link for openssl in your README is broken so i downloaded it from https://github.com/openssl/openssl/releases/tag/OpenSSL_1_0_2d

How do i install 64bit ZLIB and LIBCURL? Will it automatically override my 32-bit version if it's already installed? (Which directories in windows are they even installed to btw?)

Btw a 32-bit Simba won't be able to load a 64-bit dll right?

Brandon
12-18-2015, 04:23 AM
...

Looks like the newest version of OpenSSL officially supports 64-bit but has problems with its make-file (make-file also changed and so did the configuration).. Anyway, to get around it, use the following to build the libraries:



#For Building Zlib:

export "INCLUDE_PATH=/usr/local/include"
export "LIBRARY_PATH=/usr/local/lib"
export "BINARY_PATH=/usr/local/bin"
export "CFLAGS=-m32"
export "CXXFLAGS=-m32"
export "LDFLAGS=-m32"
make -f win32/Makefile.gcc install



#For Building OpenSSL (if you are missing any dependencies, run "make depend" before "make install"):

./configure no-shared threads --prefix=/usr/local mingw
make install



#For Building OpenSSL (with specific CPU/Architecture):

./configure no-shared threads --prefix=/usr/local -m32 -march=i686 mingw
make install



#For Building OpenSSL (without Assembly):

./configure no-shared threads --prefix=/usr/local no-asm mingw
make install


#For Listing OpenSSL CPU/OS/Architecture configurations:

./configure no-shared thread --prefix=/usr/local -m32



#For Building CurlLib:

./configure —-enable-static —-enable-shared —-enable-ipv6 —-with-ssl=/usr/local --build=i686-pc-windows "CFLAGS=-m32" "CXXFLAGS=-m32" "LDFLAGS=-m32"
make install



OpenSSL is installed in your prefix directory. You can specify --prefix=/c/OpenSSL or --prefix=/c/OpenSSL64 but in the above I just leave it as /usr/local.

If you decide to change the prefix then when building Curl, you have to specify --with-ssl=WhateverPrefixYouSpecified

Netzone
05-21-2016, 03:23 PM
Doesn't seem like I can get the library to load correctly. I mean, it obviously loads because I don't get an error when I try to load it, but when I try to use any of the functions I get a "Unknown Declaration" error.

Error: Unknown declaration "Pro_InitSocket"

Obscurity
05-21-2016, 07:28 PM
ProSocks is no longer structured like that.

Netzone
05-21-2016, 08:02 PM
ProSocks is no longer structured like that.

Oh, now I see. Does that mean there's no longer any way to connect to a socket server with the library? Since the address constant in SSLSocket and the connect, read and write functions are not there in the lape part.

Should I use the built in socket library instead?

BigRedJapan
07-10-2016, 09:38 PM
After Updating Prosocks I keep running into this error!!

Error: Unknown declaration "Pro_InitSocket" at line 624
Compiling failed.


Can anyone help?

ghostriderz
12-28-2017, 10:18 AM
Error: Unknown declaration "SSLSocket" at line 83
Compiling failed.

i downloaded prosocks and put it in plugins.
still gives this error can some1 pls help?