Portál AbcLinuxu, 1. května 2025 12:50
For one of my projects, I needed to authenticate script against service on remote IIS server - and unfortunately, only NTLM authentication was supported. So I spent pretty long time trying to make it work - and when I finally succeeded, I decided to share working program with the world .
There are several things you need to know to use this:
Firstly, the connection you open is persistent (even when you don't use pfsockopen), because you don't use Connection: Close but Connection: keep-alive. This means that you must not read even single byte from the stream if it hasn't been already sent; if you do so, you will wait for a minute until connection timeouts.
Secondly, after you successfully authenticate youself, you can send as many requests as you want in the connection that is already opened, without further authentication.
You need mcrypt and mhash PHP extension installed on the server. The class also uses this script which should be extracted in the same folder (and is already extracted with the script).
You can download the archive with script here.Pro jeden ze svých projektů jsem potřeboval skript, který by se autorizoval na vzdáleném IIS serveru - a bohužel byla podporována pouze NTLM autentizace. Takže jsem strávil nemálo času tím to rozchodit - a když se mi to nakonec povedlo, tak jsem se rozhodl se o to podělit s ostatními :)
Je několik věcí, které je dobré vědět při používání:
První - spojení, co se otevře, je perzistentní (přestože se nepoužívá pfsockopen), protože se neposílá Connection: Close, ale Connection: keep-alive. To znamená, že se nesmí z toho socketu číst více bytů, než tam server již poslal - nebo si počkáte minutu, než spojení timeoutuje.
Druhá - potom, co se úspěšně autentizujete, tak se může v tom otevřeném spojení poslat tolik requestů, kolik je jen libo - a to bez jakékoliv další autentizace.
Je potřeba mít mcrypt a mhash rozšíření PHP. Dále používám tento skript, který je potřeba rozbalit do stejné složky (a který je již přibalen ve skriptu).
Skript je ke stažení tady.
Tiskni
Sdílej:
s/authentification/authentication/
lion:~/source/john-1.7.2/run> ./john -test Benchmarking: Traditional DES [128/128 BS SSE2-16]... DONE Many salts: 1729K c/s real, 1740K c/s virtual Only one salt: 1501K c/s real, 1501K c/s virtual Benchmarking: BSDI DES (x725) [128/128 BS SSE2-16]... DONE Many salts: 57919 c/s real, 58151 c/s virtual Only one salt: 56641 c/s real, 56755 c/s virtual Benchmarking: FreeBSD MD5 [32/64 X2]... DONE Raw: 10838 c/s real, 10838 c/s virtual Benchmarking: OpenBSD Blowfish (x32) [32/64]... DONE Raw: 394 c/s real, 394 c/s virtual Benchmarking: Kerberos AFS DES [48/64 4K]... DONE Short: 361113 c/s real, 361113 c/s virtual Long: 1088K c/s real, 1090K c/s virtual Benchmarking: NT LM DES [128/128 BS SSE2-16]... DONE Raw: 10013K c/s real, 10033K c/s virtual
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.