Proxy Authenticaton

I want to know how can i check credentials via proxy for example if credentials are wrong proxy refuses to connect how can i add key for that?

You can try connecting to them via TCP commands
You will also need to base64 encode the user/pass so

echo -n user:pass| openssl base64

= dXNlcjpwYXNz

TCP Connect - Proxy Port
TCP Send/Read - GET http://www.google.com/ HTTP/1.0 \n\nProxy-Authorization: Basic dXNlcjpwYXNz

A normal Http Request block will also do the trick, set the proxy manually (look in the forum there are guides for it) and wrap the request in a try/catch, then do the keycheck on data.ERROR

@Ruri

Is it any way to check a proxy with credentials? i.e. get CORRECT user and pass for proxy auth.

Thanks, my bro

I just told you how to do it

Ruri how am i able to add key check for your method?

How will i know if user:pass are good or not?

data.Proxy = new RuriLib.Models.Proxies.Proxy(
  "127.0.0.1", 
  8888, 
  RuriLib.Models.Proxies.ProxyType.Http, 
  input.USERNAME, 
  input.PASSWORD);
  
data.UseProxy = true;

try
{
BLOCK:HttpRequest
  url = "https://example.com"
  TYPE:STANDARD
  $""
  "application/x-www-form-urlencoded"
ENDBLOCK
}
catch (Exception ex)
{
  data.ERROR = ex.ToString();
  CLOG Tomato ex.Message
}

BLOCK:Keycheck
  KEYCHAIN SUCCESS OR
    STRINGKEY @data.ERROR EqualTo ""
  KEYCHAIN FAIL OR
    STRINGKEY @data.ERROR NotEqualTo ""
ENDBLOCK

I didn’t add the SAFE checkbox for the Http Request block yet so that’s why you need some C# to do this at the moment.

@Ruri,

Nice code, my bro
I have tried one proxy, the code seems not working.
Do I need to change something when using it?
Thanks again

The TCP method also works pretty well.

If you use an invalid auth header you will get 407 Proxy Auth Required

Tried it on my squid4 proxies as well and got the admin/blocked page instead of google. Used the correct auth hash and google loads right up.

1 Like

If the proxy is HTTP he could also send the CONNECT request directly to the proxy, I think that is going to be much faster (only if HTTP though).

1 Like

@jrem, my bro,
could you please kind share your code?
thanks

Its in my first reply

You just need to convert it to LoliCode

  1. Convert user:pass to Base64
  2. TCP Connect to proxy
  3. TCP Send/Read HTML the command from above
  4. Add KeyCheck

Change GET to CONNECT or any other valid HTTP command but it will all work the same for the most part

@jrem
Appreciate!
Can not follow you step. Please kindly share or PM your code like Ruri did.
my bro

Go ahead and try to do it. Not going to build it for you but more then happy to help guide you

For Base64, search for Base64 in blocks. You want UTF8 => Base64

As for TCP requests, Goto Requests → TCP. You want Tcp Connect as the first block and Tcp Send Read Http and the 2nd.

Finally add a KeyCheck

1 Like

BLOCK:TcpSendRead
message = $“GET http://www.google.com/ HTTP/1.0 \n\nProxy-Authorization: Basic
=> VAR @tcpSendReadOutput
ENDBLOCK

BLOCK:Keycheck
banIfNoMatch = False
KEYCHAIN FAIL OR
STRINGKEY @data.HEADERS Contains “407”
KEYCHAIN SUCCESS OR
STRINGKEY @data.HEADERS Contains “200”
ENDBLOCK

@jrem try it out, but errors

The server says
HTTP/1.0 400 Bad Request

any suggestions, my bro

Post your whole config minus any identifying info or dm it to me

@jrem
My bro, here is whole config.

BLOCK:UTF8ToBase64
  input = $"<input.USERNAME>:<input.PASSWORD>"
  => VAR @B64
ENDBLOCK

BLOCK:TcpConnect
  host = "127.0.0.1"
  port = 3128
ENDBLOCK

BLOCK:TcpSendRead
  message = $"GET http://www.google.com/ HTTP/1.0\\n\\nProxy-Authorization: Basic <B64>"
  => VAR @tcpSendReadOutput
ENDBLOCK

BLOCK:Keycheck
  KEYCHAIN FAIL OR
    STRINGKEY @data.HEADERS Contains "407"
  KEYCHAIN SUCCESS OR
    STRINGKEY @data.HEADERS Contains "200"
ENDBLOCK

1st this needs to be

message = $"GET http://www.google.com/ HTTP/1.0\n\nProxy-Authorization: Basic <B64>"

2nd it should be TCP Send Read HTTP command not a TCP Send Read command

Usually it’s \r\n for a newline in HTTP