The process cannot access the file because it is being used

 
Post new topic   Reply to topic    Aprelium Forum Index -> FastCGI/CGI
View previous topic :: View next topic  
Author Message
lazna
-


Joined: 16 Aug 2015
Posts: 44

PostPosted: Thu Aug 12, 2021 4:33 pm    Post subject: The process cannot access the file because it is being used Reply with quote

Have cmd script which generating HTML code utilizing batwrap.exe. In output page, there are four <img src="script.cmd"> tags. This are linked to scripts which generate images dynamically (as a result of scripts). The page itself load imediatelly, but single images appears few secs later, as scripts finish and produce output. Its how it WAS works a years earlier when I use this technique on Windows 2003.

Now trying this technique on Windows 10 but only one of this four images appear, last three are not displayed (only empty image frame with proper dimesions). When perform right-click on this three frames and select "Reload image" option, it load in few secs, as expected. All of them one by one.

After load this page, there are trhee lines of %SUBJ% in Abyss cgi.log What is going wrong? I do not writing to any file (exclusive access), only reading files (different file for each image), creating images on-the-fly (into STDOUT). Where the problem could be?
Back to top View user's profile Send private message
admin
Site Admin


Joined: 03 Mar 2002
Posts: 1178

PostPosted: Thu Aug 19, 2021 9:44 pm    Post subject: Re: The process cannot access the file because it is being u Reply with quote

lazna,

Without inspecting your code, we could not make any informed suggestion. Is it possible to send us your abyss.conf as well as your code for the .cmd files for review?

What is the origin of %SUBJ%? Is it in your code?
_________________
Follow @abyssws on Twitter
Subscribe to our newsletter
_________________
Forum Administrator
Aprelium - https://aprelium.com
Back to top View user's profile Send private message
lazna
-


Joined: 16 Aug 2015
Posts: 44

PostPosted: Fri Aug 20, 2021 10:09 am    Post subject: Reply with quote

I have no access to this machine now, but my colegue send me Procmon logfile in the mean time. Logfile contain time range of few seconds from moment the web link was clicked.

Could this help?

https://www.uschovna.cz/zasilka/OXGGWHEMDVERS576-F5G/RLL9L3Z7DN
Back to top View user's profile Send private message
admin
Site Admin


Joined: 03 Mar 2002
Posts: 1178

PostPosted: Sat Aug 21, 2021 4:57 pm    Post subject: Reply with quote

lazna wrote:
I have no access to this machine now, but my colegue send me Procmon logfile in the mean time. Logfile contain time range of few seconds from moment the web link was clicked.

Could this help?

https://www.uschovna.cz/zasilka/OXGGWHEMDVERS576-F5G/RLL9L3Z7DN


Is there an anti-malware or an antivirus that is doing some time consuming checks when when these .cmd files are launched?

More information about the context is what could help us understand this issue.
_________________
Follow @abyssws on Twitter
Subscribe to our newsletter
_________________
Forum Administrator
Aprelium - https://aprelium.com
Back to top View user's profile Send private message
lazna
-


Joined: 16 Aug 2015
Posts: 44

PostPosted: Sat Aug 21, 2021 10:30 pm    Post subject: Reply with quote

All scripts are here. Firts create HTML page containing <IMG> tags calling graphs generators. Second script is graph generator itself. Antivirus is bouilt-in windows defender, batwrap.exe is listed in excluded processes. Just trying test with antivirus real-time monitoring turned off, but same results... Third scripts is just for completeness

Code:
@echo off
::
:: This script print html page and call 'TRAFFIC_graph_creator.cmd' to print traffic
:: on selected interfaces of specific routers
::
echo Content-Type: text/html
echo.
echo ^<!doctype html^>
echo ^<html^>
echo ^<head^>
echo ^<meta http-equiv="Content-Type" content="text/html; charset=utf-8"^>
echo ^<title^>
echo Traffic statistics
echo ^</title^>
echo ^</head^>
echo ^<body^>^<font size="5"^>^<table^>
set "host=10.10.0.5"
set "iface=vlan206"
echo ^<tr^>^<td^> [%iface%@%host%]:^</td^>^</tr^>
echo ^<tr^>^<td background="images/message.gif" style="background-repeat:no-repeat;background-position:center;"^>^<img src="TRAFFIC_graph_creator.cmd?host=%host%&iface=%iface%" width="1066" height="355"^>^</td^>^</tr^>
set "host=10.10.0.1"
set "iface=vlan4091"
echo ^<tr^>^<td^> [%iface%@%host%]:^</td^>^</tr^>
echo ^<tr^>^<td background="images/message.gif" style="background-repeat:no-repeat;background-position:center;"^>^<img src="TRAFFIC_graph_creator.cmd?host=%host%&iface=%iface%" width="1066" height="355"^>^</td^>^</tr^>
set "host=10.10.0.9"
set "iface=eth0.401"
echo ^<tr^>^<td^> [%iface%@%host%]:^</td^>^</tr^>
echo ^<tr^>^<td background="images/message.gif" style="background-repeat:no-repeat;background-position:center;"^>^<img src="TRAFFIC_graph_creator.cmd?host=%host%&iface=%iface%" width="1066" height="355"^>^</td^>^</tr^>
set "host=10.10.0.2"
set "iface=eth4.311"
echo ^<tr^>^<td^> [%iface%@%host%]:^</td^>^</tr^>
echo ^<tr^>^<td background="images/message.gif" style="background-repeat:no-repeat;background-position:center;"^>^<img src="TRAFFIC_graph_creator.cmd?host=%host%&iface=%iface%" width="1066" height="355"^>^</td^>^</tr^>
echo ^</font^>^</body^>^</html^>



Code:
@echo off
::
:: This script print create traffic graph from RRDfiles, based on 'host' and 'iface'
:: given in parameters. Output is controlled by REMOTE_ADDR variable presence.
::
::
echo Content-Type: image/png
echo.
set "rrdtool=c:\inetpub\monitoring_test\utilities\rrdtool\rrdtool.exe"
set "logfile=logs\%~n0.log"
REM == If started from console, check parameters presence ======================
if not defined REMOTE_ADDR (
            set "output=c:\inetpub\monitoring_test\temp\graph.png"
            if "%~2"=="" (
                        echo "Parameter missing. Usage: %~nx0 [host] [iface]"
                        exit /B
                        ) else (
                        set "iface=%~2"
                        if not "%~1"=="" (
                                    set "host=%~1"
                                    ) else (
                                    echo "Parameter missing. Usage %~nx0 [host] [iface]"
                                    exit /B
                                    )
                        )
            ) else (
            call "functions\read_POST.cmd" "%QUERY_STRING%"
            set "output=-"
            )
::
call :print_graph
exit /B

:print_graph
%rrdtool% ^
graph %output% ^
-w 1000 ^
-h 300 ^
-i ^
--disable-rrdtool-tag ^
--imgformat PNG ^
--end=-300 ^
--start=-115000 ^
DEF:traf1=X\:\RRD\ROUTERS\%host%\%iface%.rrd:traf1:AVERAGE ^
DEF:traf2=X\:\RRD\ROUTERS\%host%\%iface%.rrd:traf2:AVERAGE ^
CDEF:traf1_=traf1,-8,* ^
CDEF:traf2_=traf2,8,* ^
AREA:traf1_#00eb0c:"Traffic 1" ^
AREA:traf2_#1000ff:"Traffic 2" 2>>%logfile%
GOTO:EOF





Code:
::
:: This function read STDIN (http GET string), perform URLDecode and convert
:: encoding to UTF-8. If any parameter provided, parse it instead of script STDIN
::
:: require: win_iconv.exe
::
::
::
if "%~1"=="" (
REM == If no parameter provided, parse script STDIN [usually HTTP GET]
      for /f "tokens=1-26 delims=&" %%a in ('
               powershell.exe -noprofile "Add-Type -AssemblyName System.Web;[System.Web.HttpUtility]::UrlDecode($Input) | Write-Host" ^| win_iconv -f CP852 -t UTF-8
               ') do (
               if not "%%~a"=="" set "%%~a"
               if not "%%~b"=="" set "%%~b"
               if not "%%~c"=="" set "%%~c"
               if not "%%~d"=="" set "%%~d"
               if not "%%~e"=="" set "%%~e"
               if not "%%~f"=="" set "%%~f"
               if not "%%~g"=="" set "%%~g"
               if not "%%~h"=="" set "%%~h"
               if not "%%~i"=="" set "%%~i"
               if not "%%~j"=="" set "%%~j"
               if not "%%~k"=="" set "%%~k"
               if not "%%~l"=="" set "%%~l"
               if not "%%~m"=="" set "%%~m"
               if not "%%~n"=="" set "%%~n"
               if not "%%~o"=="" set "%%~o"
               if not "%%~p"=="" set "%%~p"
               if not "%%~q"=="" set "%%~q"
               if not "%%~r"=="" set "%%~r"
               if not "%%~s"=="" set "%%~s"
               if not "%%~t"=="" set "%%~t"
               if not "%%~u"=="" set "%%~u"
               if not "%%~v"=="" set "%%~v"
               if not "%%~w"=="" set "%%~w"
               if not "%%~x"=="" set "%%~x"
               if not "%%~y"=="" set "%%~y"
               if not "%%~z"=="" set "%%~z"
               if not defined REMOTE_ADDR echo %~nx0_out --- TOKENS "%%~a" "%%~b" "%%~c" "%%~d" "%%~e" "%%~f" "%%~g" "%%~h" "%%~i" "%%~j" "%%~k" "%%~l" "%%~m" "%%~n" "%%~o" "%%~p" "%%q" "%%~r" "%%~s" "%%~t" "%%~u" "%%~v" "%%w" "%%~x" "%%~y" "%%~z"
               )
        ) else (
REM == If parameter provided, send it to STDIN to be parsed [usually console DEBUG]
REM == [Echoed strind HAVE to be doublequoted, othervise delimiters '=' diasppaer]
        for /f "tokens=1-26 delims=#&" %%a in ('
               echo "%~1"^| powershell.exe -noprofile "Add-Type -AssemblyName System.Web;[System.Web.HttpUtility]::UrlDecode($Input) | Write-Host" ^| win_iconv -f CP852 -t UTF-8
               ') do (
               if not "%%~a"=="" set "%%~a"
REM == Missing trailing doublequote is an intend [hack od remaining one from echo "%~1"]
               if not "%%~b"=="" set "%%~b
               if not "%%~c"=="" set "%%~c"
               if not "%%~d"=="" set "%%~d"
               if not "%%~e"=="" set "%%~e"
               if not "%%~f"=="" set "%%~f"
               if not "%%~g"=="" set "%%~g"
               if not "%%~h"=="" set "%%~h"
               if not "%%~i"=="" set "%%~i"
               if not "%%~j"=="" set "%%~j"
               if not "%%~k"=="" set "%%~k"
               if not "%%~l"=="" set "%%~l"
               if not "%%~m"=="" set "%%~m"
               if not "%%~n"=="" set "%%~n"
               if not "%%~o"=="" set "%%~o"
               if not "%%~p"=="" set "%%~p"
               if not "%%~q"=="" set "%%~q"
               if not "%%~r"=="" set "%%~r"
               if not "%%~s"=="" set "%%~s"
               if not "%%~t"=="" set "%%~t"
               if not "%%~u"=="" set "%%~u"
               if not "%%~v"=="" set "%%~v"
               if not "%%~w"=="" set "%%~w"
               if not "%%~x"=="" set "%%~x"
               if not "%%~y"=="" set "%%~y"
               if not "%%~z"=="" set "%%~z"
               if not defined REMOTE_ADDR echo %~nx0_out --- TOKENS "%%~a" "%%~b" "%%~c" "%%~d" "%%~e" "%%~f" "%%~g" "%%~h" "%%~i" "%%~j" "%%~k" "%%~l" "%%~m" "%%~n" "%%~o" "%%~p" "%%q" "%%~r" "%%~s" "%%~t" "%%~u" "%%~v" "%%w" "%%~x" "%%~y" "%%~z"
               )
        )
exit /B
Back to top View user's profile Send private message
admin
Site Admin


Joined: 03 Mar 2002
Posts: 1178

PostPosted: Sun Aug 22, 2021 9:11 pm    Post subject: Reply with quote

lazna,

The scripts are a bit complex and it could be any of the called programs or sub-scripts that is the cause of this issue.

Try first activating CGI logging for that host and checking the resulting log file. What does it report for the first bad attempt with the 3 missing images?

How are these logged in the access.log file? What status code is reported for them.

Can you send to support@aprelium.com your abyss.conf file for review too?
_________________
Follow @abyssws on Twitter
Subscribe to our newsletter
_________________
Forum Administrator
Aprelium - https://aprelium.com
Back to top View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> FastCGI/CGI All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group