-
-
Save jesusninoc/760f1c542389bae7119fc3536775da4a to your computer and use it in GitHub Desktop.
Revisions
-
staaldraad revised this gist
Feb 24, 2017 . 1 changed file with 6 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,16 +11,16 @@ $fileStream = New-Object System.IO.FileStream($file, [System.IO.FileMode]'Create do { $read = $null; while($stream.DataAvailable -or $read -eq $null) { $read = $stream.Read($buffer, 0, 2048); if ($read -gt 0) { $fileStream.Write($buffer, 0, $read); } } } While ($read -gt 0); $fileStream.Close(); $socket.Stop(); $client.close(); $stream.Dispose(); -
staaldraad created this gist
Feb 24, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ $socket = new-object System.Net.Sockets.TcpListener('0.0.0.0', 1080); if($socket -eq $null){ exit 1; } $socket.start(); $client = $socket.AcceptTcpClient(); $stream = $client.GetStream(); $buffer = new-object System.Byte[] 2048; $file = 'c:/afile.exe'; $fileStream = New-Object System.IO.FileStream($file, [System.IO.FileMode]'Create', [System.IO.FileAccess]'Write'); do { $read = $null; while($stream.DataAvailable -or $read -eq $null) { $read = $stream.Read($buffer, 0, 2048); if ($read -gt 0) { $fileStream.Write($buffer, 0, $read); } } } While ($read -gt 0); $fileStream.Close(); $socket.Stop(); $client.close(); $stream.Dispose();