Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Shell 

[MakeFTPserver.cmd] - UPDATE: ver2 - creates FTP-server on localhost

this is version2,
read the header-comments at the beginning of the batch-file to see whats changed since version1


its not a huge difference but its enough of a difference to be worth posting,
mainly because of the new custom ftp server splash-screen/welcome-message function



MakeFTPserver.cmd
Code
@goto :batch

=================================================================================================================================
this is verssion2, only changes made are:
1)added function of choosing a custom splash-screen/welcome-message for the FTP-server instead of using IIS's default
2)more acurate wording of what the "turn-off" function in the main-menu does by labling it as "disable" not "remove"
3)an internal code-efficentcy change of calling macro "setupserver_header" to display some of the text you see at each
step of setting up the ftp-server instead of re-typing the same "echo" commands over and over at each step that displays them
=================================================================================================================================

:batch
@echo off
title %~n0
echo.>"%homedrive%\AdminPriv.test"
if exist "%homedrive%\AdminPriv.test" goto :has_uac_elev
cls
echo.requesting UAC elevation ...
echo.set x = createobject("shell.application")>"%temp%\uacelev.vbs"
echo.x.shellexecute "%comspec%","/D /C "^&chr("34")^&"@%~dpnx0"^&chr("34"),"%homedrive%\","runas",1 >>"%temp%\uacelev.vbs"
echo.x.shellexecute "%comspec%","/D /C @del /f /q "^&chr("34")^&wscript.scriptfullname^&chr("34"),"%homedrive%\","open",0 >>"%temp%\uacelev.vbs"
start "" "%temp%\uacelev.vbs"
exit
:has_uac_elev
del /f /q "%homedrive%\AdminPriv.test" >nul
mode con: cols=90 lines=20
:mainmenu
cls
echo.--
echo.hosting an FTP-server on this computer:
echo.--
echo.
echo.
echo.tap "s" to set-up or edit FTP-server
echo.tap "d" to disable FTPserver
choice /c sd >nul
cls
if %errorlevel% EQU 1 call :setupserver
if %errorlevel% EQU 2 call :removeserver
goto :mainmenu


:setupserver
set "showsetupheader=call :setupserver_header"
%showsetupheader%
echo.select a port to host FTP server on:
echo.leave blank to use standard FTP-port (port 21)
set/p "port=[PORT]:"
if "%port%"=="" set "port=21"
%showsetupheader%
echo.select a folder to use as the FTPserver's file directory
echo.if the folder you choose does not exist it will be created
echo.leave blank to use default location "%homedrive%\FTPserverFiles"
set/p "ftprootdirectory=[folder]:"
if "%ftprootdirectory%"=="" set "ftprootdirectory=%homedrive%\FTPserverFiles"
if NOT exist "%ftprootdirectory%" mkdir "%ftprootdirectory%"
%showsetupheader%
echo.set-up the server's Welcome-Message/Spash-Screen:
echo.leave blank to use the default WelcomeMessage "Welcome! Please log-in."
set/p "welcomemsg=[WelcomeMessage]:"
if "%welcomemsg%"=="" set "welcomemsg=Welcome! Please log-in."
%showsetupheader%
echo.windows users will be the username and passwords used to log into the FTP-server
echo.all of them have full access to read/write/modify files on the FTP-server
echo.
echo.tap ^<space^> to create the FTP-server
pause >nul
cls
echo.setting up FTP-server, this may take a few minutes ...
DISM /Online /Enable-Feature /FeatureName:IIS-WebServerRole >nul
DISM /Online /Enable-Feature /FeatureName:IIS-FTPServer >nul
DISM /Online /Enable-Feature /FeatureName:IIS-FTPSvc >nul
DISM /Online /Enable-Feature /FeatureName:IIS-FTPExtensibility >nul
"%windir%\system32\inetsrv\appcmd.exe" DELETE SITE hostedFTPserver >nul
"%windir%\system32\inetsrv\appcmd.exe" ADD SITE /name:hostedFTPserver /bindings:ftp://*:%port% /PhysicalPath:"%ftprootdirectory%" >nul
icacls "%ftprootdirectory%" /Grant "Network Service":F /T  >nul
"%windir%\system32\inetsrv\appcmd.exe" set config -section:system.applicationHost/sites /[name='hostedFTPserver'].ftpServer.security.ssl.controlChannelPolicy:"SslAllow" >nul
"%windir%\system32\inetsrv\appcmd.exe" set config -section:system.applicationHost/sites /[name='hostedFTPserver'].ftpServer.security.ssl.dataChannelPolicy:"SslAllow" >nul
"%windir%\system32\inetsrv\appcmd.exe" set config -section:system.applicationHost/sites /[name='hostedFTPserver'].ftpServer.security.authentication.basicAuthentication.enabled:true >nul
"%windir%\system32\inetsrv\appcmd.exe" set config -section:system.applicationHost/sites /[name='hostedFTPserver'].ftpServer.messages.bannerMessage:"%welcomemsg%" /commit:apphost
"%windir%\system32\inetsrv\appcmd.exe" set config -section:system.applicationHost/sites /[name='hostedFTPserver'].ftpServer.messages.suppressDefaultBanner:"True" /commit:apphost
"%windir%\system32\inetsrv\appcmd.exe" set config hostedFTPserver /section:system.ftpserver/security/authorization /+[accessType='Allow',permissions='Read,Write',roles='',users='*'] /commit:apphost >nul
netsh int portproxy add v4tov4 listenport=80 connectaddress=127.0.0.1 connectport=21
cls
echo.--
echo.FTP-server created on port: [ %port% ]
echo.FTP-server's file directory is [ %ftprootdirectory% ]
echo.--
echo.
echo.--
echo.use your windows users' username ^& passwords to log into the FTP-server
echo.they will all have read/write/modify permissions
echo.--
echo.
echo.
echo.tap ^<space^> to continue
pause >nul
goto :end

:setupserver_header
cls
echo.--
echo.setting FTP-server settings
echo.--
echo.
echo.
goto :end


:removeserver
echo.disableing FTP-server ...
"%windir%\system32\inetsrv\appcmd.exe" DELETE SITE hostedFTPserver >nul
call netsh int portproxy delete v4tov4 listenport=80 >nul
echo.
echo.
echo.FTP-server is now disabled.
echo.tap ^<space^> to continue
pause >nul

:end
Hey, wow I didn't know Windows had an inbuilt FTP function, I'll test this out :)

Guess I need open ports on my router? In that case I'll test tomorrow, I need sleep right now!

Just a quick note, use REM or :: to comment out the writing at the start :)
(Though :: is really just a bug with the labels, it works)
Keep me fed and alive at Uni: Bitcoin Bitcoin: 16cwoYXfhaK6V5c8kJKn9SBMtDUARUs7BS
I'll draw terrible art in paint.NET for you, on request, in return <3
(Aug 9, 2016 04:41 PM)gogglebot Wrote:  Hey, wow I didn't know Windows had an inbuilt FTP function, I'll test this out :)

Guess I need open ports on my router? In that case I'll test tomorrow, I need sleep right now!

Just a quick note, use REM or :: to comment out the writing at the start :)
(Though :: is really just a bug with the labels, it works)
windows has a built in webserver component thats by default disabled that for some reason doesnt come with php called IIS, i just enabled spicifically only the parts of it u need to to enable ftp then forwarded the http port to the ftp server's port as a shortcut to disable the other parts of IIS i had to enable to enable ftp. other than that this script is just custom options like what port to host the ftp server on, which windows folder u want to use as your ftp root, ect.
Testing now, first issue is invoking the elevated prompt didn't quite work, it generated the UAC popup, ran again, and immediately CTD, right clicking the file and running as admin works fine, though :) I'm on Win10
Secondly, You can press any button not just space to continue after the "Press <space> to continue" parts, but that's just me being picky :p
Keep me fed and alive at Uni: Bitcoin Bitcoin: 16cwoYXfhaK6V5c8kJKn9SBMtDUARUs7BS
I'll draw terrible art in paint.NET for you, on request, in return <3
(Aug 10, 2016 12:52 PM)gogglebot Wrote:  Testing now, first issue is invoking the elevated prompt didn't quite work, it generated the UAC popup, ran again, and immediately CTD

CTD? what do u mean by that? and if youre on vista that will happen unless u change one line of of the code by 1 character, adding a space

this is the section of the original code that needs to b changed to not get UAC prompt after UAC prompt over and over on vista
Code
:batch
@echo off
title %~n0
echo.>"%homedrive%\AdminPriv.test"
change the last line of that to:
Code
echo. >"%homedrive%\AdminPriv.test"
add a space between the period (".") and the redirect-output sign (">")
(Aug 10, 2016 01:11 PM)ImDeepWithWindows Wrote:  CTD? what do u mean by that? and if youre on vista that will happen unless u change one line of of the code by 1 character, adding a space
Crash To Desktop, e.g. the program just vanished without an error message visible.

(Aug 10, 2016 01:11 PM)ImDeepWithWindows Wrote:  this is the section of the original code that needs to b changed to not get UAC prompt after UAC prompt over and over on vista
Code
:batch
@echo off
title %~n0
echo.>"%homedrive%\AdminPriv.test"
change the last line of that to:
Code
echo. >"%homedrive%\AdminPriv.test"
add a space between the period (".") and the redirect-output sign (">")

Ah okay, however I'm not on Vista, I'll see if this fixes it on 10

Still didn't work. No idea why, I can't test it to see what error it throws because even if I run the cmd from a prompt it closes it and opens itself again, so as soon as it crashes it closes.
Keep me fed and alive at Uni: Bitcoin Bitcoin: 16cwoYXfhaK6V5c8kJKn9SBMtDUARUs7BS
I'll draw terrible art in paint.NET for you, on request, in return <3
(Aug 10, 2016 04:05 PM)gogglebot Wrote:  Crash To Desktop, e.g. the program just vanished without an error message visible.


Ah okay, however I'm not on Vista, I'll see if this fixes it on 10

Still didn't work. No idea why, I can't test it to see what error it throws because even if I run the cmd from a prompt it closes it and opens itself again, so as soon as it crashes it closes.

oh, idk whats going on then ive never used win 10, maybe they removed some of the system files the script calls on, it works on win 7 & win 8. oh well
how can i access ftp after i install it?
(Aug 9, 2016 04:41 PM)gogglebot Wrote:  Hey, wow I didn't know Windows had an inbuilt FTP function, I'll test this out :)

Guess I need open ports on my router? In that case I'll test tomorrow, I need sleep right now!

Just a quick note, use REM or :: to comment out the writing at the start :)
(Though :: is really just a bug with the labels, it works)

thanks for looking out, i already know the "rem" remark command i just like doing it this way instead

(Dec 21, 2016 11:24 PM)ford_0008 Wrote:  how can i access ftp after i install it?

open command prompt and type "ftp localhost"
Can you send me cmd to enable me to use it...
(Aug 6, 2016 06:50 PM)ImDeepWithWindows Wrote:  this is version2,
read the header-comments at the beginning of the batch-file to see whats changed since version1


its not a huge difference but its enough of a difference to be worth posting,
mainly because of the new custom ftp server splash-screen/welcome-message function



MakeFTPserver.cmd
Code
@goto :batch

=================================================================================================================================
this is verssion2, only changes made are:
1)added function of choosing a custom splash-screen/welcome-message for the FTP-server instead of using IIS's default
2)more acurate wording of what the "turn-off" function in the main-menu does by labling it as "disable" not "remove"
3)an internal code-efficentcy change of calling macro "setupserver_header" to display some of the text you see at each
step of setting up the ftp-server instead of re-typing the same "echo" commands over and over at each step that displays them
=================================================================================================================================

:batch
@echo off
title %~n0
echo.>"%homedrive%\AdminPriv.test"
if exist "%homedrive%\AdminPriv.test" goto :has_uac_elev
cls
echo.requesting UAC elevation ...
echo.set x = createobject("shell.application")>"%temp%\uacelev.vbs"
echo.x.shellexecute "%comspec%","/D /C "^&chr("34")^&"@%~dpnx0"^&chr("34"),"%homedrive%\","runas",1 >>"%temp%\uacelev.vbs"
echo.x.shellexecute "%comspec%","/D /C @del /f /q "^&chr("34")^&wscript.scriptfullname^&chr("34"),"%homedrive%\","open",0 >>"%temp%\uacelev.vbs"
start "" "%temp%\uacelev.vbs"
exit
:has_uac_elev
del /f /q "%homedrive%\AdminPriv.test" >nul
mode con: cols=90 lines=20
:mainmenu
cls
echo.--
echo.hosting an FTP-server on this computer:
echo.--
echo.
echo.
echo.tap "s" to set-up or edit FTP-server
echo.tap "d" to disable FTPserver
choice /c sd >nul
cls
if %errorlevel% EQU 1 call :setupserver
if %errorlevel% EQU 2 call :removeserver
goto :mainmenu


:setupserver
set "showsetupheader=call :setupserver_header"
%showsetupheader%
echo.select a port to host FTP server on:
echo.leave blank to use standard FTP-port (port 21)
set/p "port=[PORT]:"
if "%port%"=="" set "port=21"
%showsetupheader%
echo.select a folder to use as the FTPserver's file directory
echo.if the folder you choose does not exist it will be created
echo.leave blank to use default location "%homedrive%\FTPserverFiles"
set/p "ftprootdirectory=[folder]:"
if "%ftprootdirectory%"=="" set "ftprootdirectory=%homedrive%\FTPserverFiles"
if NOT exist "%ftprootdirectory%" mkdir "%ftprootdirectory%"
%showsetupheader%
echo.set-up the server's Welcome-Message/Spash-Screen:
echo.leave blank to use the default WelcomeMessage "Welcome! Please log-in."
set/p "welcomemsg=[WelcomeMessage]:"
if "%welcomemsg%"=="" set "welcomemsg=Welcome! Please log-in."
%showsetupheader%
echo.windows users will be the username and passwords used to log into the FTP-server
echo.all of them have full access to read/write/modify files on the FTP-server
echo.
echo.tap ^<space^> to create the FTP-server
pause >nul
cls
echo.setting up FTP-server, this may take a few minutes ...
DISM /Online /Enable-Feature /FeatureName:IIS-WebServerRole >nul
DISM /Online /Enable-Feature /FeatureName:IIS-FTPServer >nul
DISM /Online /Enable-Feature /FeatureName:IIS-FTPSvc >nul
DISM /Online /Enable-Feature /FeatureName:IIS-FTPExtensibility >nul
"%windir%\system32\inetsrv\appcmd.exe" DELETE SITE hostedFTPserver >nul
"%windir%\system32\inetsrv\appcmd.exe" ADD SITE /name:hostedFTPserver /bindings:ftp://*:%port% /PhysicalPath:"%ftprootdirectory%" >nul
icacls "%ftprootdirectory%" /Grant "Network Service":F /T  >nul
"%windir%\system32\inetsrv\appcmd.exe" set config -section:system.applicationHost/sites /[name='hostedFTPserver'].ftpServer.security.ssl.controlChannelPolicy:"SslAllow" >nul
"%windir%\system32\inetsrv\appcmd.exe" set config -section:system.applicationHost/sites /[name='hostedFTPserver'].ftpServer.security.ssl.dataChannelPolicy:"SslAllow" >nul
"%windir%\system32\inetsrv\appcmd.exe" set config -section:system.applicationHost/sites /[name='hostedFTPserver'].ftpServer.security.authentication.basicAuthentication.enabled:true >nul
"%windir%\system32\inetsrv\appcmd.exe" set config -section:system.applicationHost/sites /[name='hostedFTPserver'].ftpServer.messages.bannerMessage:"%welcomemsg%" /commit:apphost
"%windir%\system32\inetsrv\appcmd.exe" set config -section:system.applicationHost/sites /[name='hostedFTPserver'].ftpServer.messages.suppressDefaultBanner:"True" /commit:apphost
"%windir%\system32\inetsrv\appcmd.exe" set config hostedFTPserver /section:system.ftpserver/security/authorization /+[accessType='Allow',permissions='Read,Write',roles='',users='*'] /commit:apphost >nul
netsh int portproxy add v4tov4 listenport=80 connectaddress=127.0.0.1 connectport=21
cls
echo.--
echo.FTP-server created on port: [ %port% ]
echo.FTP-server's file directory is [ %ftprootdirectory% ]
echo.--
echo.
echo.--
echo.use your windows users' username ^& passwords to log into the FTP-server
echo.they will all have read/write/modify permissions
echo.--
echo.
echo.
echo.tap ^<space^> to continue
pause >nul
goto :end

:setupserver_header
cls
echo.--
echo.setting FTP-server settings
echo.--
echo.
echo.
goto :end


:removeserver
echo.disableing FTP-server ...
"%windir%\system32\inetsrv\appcmd.exe" DELETE SITE hostedFTPserver >nul
call netsh int portproxy delete v4tov4 listenport=80 >nul
echo.
echo.
echo.FTP-server is now disabled.
echo.tap ^<space^> to continue
pause >nul

:end

Thank you for that one! 👍
(Mar 10, 2017 01:17 AM)ford_0008 Wrote:  Can you send me cmd to enable me to use it...

what you accidentally copied a file over cmd.exe or soemething?, im down to send u a copy of cmd.exe

cmd.exe is not a file thats cross-compatible with all versions of windows so
u usually have 2 get a copy of the same release of cmd.exe that came with your win OS, i got win7 & winVista virutal machines, a win10 laptop (right now it wont turn on charging system fucked up & needs 2 b fixed getting it repaired soon), and an old hard-drive of a win8.1 laptop i used to use that i got turned into a usb external hard-drive

********************************************************
baisically if you need a new cmd.exe file you'll probably need to get a copy of it off a computer that has the same win OS as yours or it wont probably work on your computer,
just in-case youre serious about this i highlighted all the cmd versions i can send u copies of in green 2 make it easier 2 c if i have one that works 4 u ********************************************************
--

(Mar 10, 2017 08:30 AM)Member Details Wrote:  Thank you for that one! 👍

thanks,
i saw some php in your posts & i was wondering such u do php if u know how to could help me out with fixing one little thing in a php script i have if u got a moment?



it has 2 do with sockets,
basically the easiest best simplest way to fix my problem would be to bind the sockets im using to the server instead of using the "stream_socket_server()" command like im doing right now,
Code
if ($hostchatroom = @stream_socket_server("tcp://0.0.0.0:".$_REQUEST['port'])) {
...
}
do u anything about how to do that? binding sockets to the server?
(Mar 13, 2017 06:41 AM)ImDeepWithWindows Wrote:  what you accidentally copied a file over cmd.exe or soemething?, im down to send u a copy of cmd.exe

cmd.exe is not a file thats cross-compatible with all versions of windows so
u usually have 2 get a copy of the same release of cmd.exe that came with your win OS, i got win7 & winVista virutal machines, a win10 laptop (right now it wont turn on charging system fucked up & needs 2 b fixed getting it repaired soon), and an old hard-drive of a win8.1 laptop i used to use that i got turned into a usb external hard-drive

********************************************************
baisically if you need a new cmd.exe file you'll probably need to get a copy of it off a computer that has the same win OS as yours or it wont probably work on your computer,
just in-case youre serious about this i highlighted all the cmd versions i can send u copies of in green 2 make it easier 2 c if i have one that works 4 u ********************************************************
--


thanks,
i saw some php in your posts & i was wondering such u do php if u know how to could help me out with fixing one little thing in a php script i have if u got a moment?



it has 2 do with sockets,
basically the easiest best simplest way to fix my problem would be to bind the sockets im using to the server instead of using the "stream_socket_server()" command like im doing right now,
Code
if ($hostchatroom = @stream_socket_server("tcp://0.0.0.0:".$_REQUEST['port'])) {
...
}
do u anything about how to do that? binding sockets to the server?

Hi! Thanks, I know quite a bit of PHP and MySQL, but I am not sure that I know about binding sockets to a server. I am learning, and perhaps may not be able to help you out in this case. You may ask for help whenever you want, though. I suggest you look out for a PHP expert on HF. 👍 Good luck!


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by TerminallyIllNov 15, 2019 09:16 PM 10 369 Nov 15, 2019 09:16 PM
Last Post: malpwn
[Shell] by compact5Jun 7, 2017 05:09 PM 1 140 Jun 7, 2017 05:09 PM
Last Post: ihatevim
[Shell] by ImDeepWithWindowsJan 20, 2017 02:07 PM 1 307 Jan 20, 2017 02:07 PM
Last Post: DataBuster