Paip. asp vbs call PHP code through CLI

Source: Internet
Author: User

Paip. asp vbs call PHP code through CLI

A few days ago, ASP used the custom encryption algorithm to call PHP parameter transfer, or wanted to use the des standard encryption algorithm to process parameters ..

And yes, you want to use ASP to call the local php des algorithm through the CLI interface, and then send it to the remote php module after encryption ..

Capture the console output ..

1. The following three lines of code Call Command Line

Set wshshell = server. Createobject ("wscript. Shell ")
CommandLine = "CMD/c: \ Users \ Administrator \ Desktop \ phprun. Bat" & MSG &"

"& Key
Set oexec = wshshell. Exec (CommandLine)

2. Call the BAT file phprun. bat first .. The main action of this file is to switch to the directory where desapi. php is located, and then

Call PHP. EXE
@ D:
@ Cd "D: \ ucenter_1.6.0_ SC _utf8 \ upload \ m_dx \"
@ "C: \ Wamp \ bin \ PHP \ php5.2.6 \ php.exe"-c: \ Wamp \ bin \ apache \ apache2.2.8 \ bin

\ PHP. ini-F "D: \ ucenter_1.6.0_ SC _utf8 \ upload \ m_dx \ desapi. php" % 1% 2

3. In desapi. php, the Code is as follows:
$ Param = $ argv [1];
$ Key = $ argv [2]; // "iluvnjyn ";
$ Val = des: encrypt ($ key, $ PARAM );
Echo ($ Val );

---------------- Prompt about insufficient permissions when running ASP wscript. Shell -------------------
My name is win7, iis7.5
First, check the user of the w3wp process. Generally, the application pool name is the same .. Then add "IIS apppool \ User Name"

In the Admin group, the user name cannot be hidden from user management .. However, you can fill in and then click OK ..
Then restart IIS to apply this account permission ..

Refer to the mysterious applicationpoolidentity in iis7.5.

 

------------------------------- ASP source code is as follows ---------------------
<%

'For test
Desfromphpresult = "" 'returns the des result of PHP.
Errmsg = "" 'error console output
Stdmsg = "" 'standard console output
Msg_l715 = "admin"
Key_l715 = "iluvnjyn"

Temp = desfromphp (msg_l715, key_l715)
If (desfromphpresult = "") then
Response. Write ("Err:" & errmsg & "<p> stdout:" & stdmsg)
Else
Response. Write ("sucess:" & desfromphpresult)
End if
%>

<%
'Ati 2012.7.18
'Sleep unit: milliseconds
Sub mysleep (mysleeptime)
Dim mytime
Mytime = timer () * 1000
 
While timer () * 1000-mytime <mysleeptime
'Wscript. Echo (timer () * 1000-mytime)
'Wscript. Echo (vbcrlf)
Wend
End sub

'Call mysleep (200)
'Ati 2012.7.18
'Return the des result of PHP
Desfromphpresult = ""
Errmsg = "" 'error console output
Stdmsg = "" 'standard console output

Function desfromphp (MSG, key)
'Dim key
'Key = "iluvnjyn"
Set wshshell = server. Createobject ("wscript. Shell ")
CommandLine = "CMD/c: \ Users \ Administrator \ Desktop \ phprun. Bat" & MSG &"

"& Key
Set oexec = wshshell. Exec (CommandLine)

'Wait for execution to complete. 0 indicates execution in progress, and 1 indicates completion.
Do While oexec. Status = 0
Call mysleep (200)
Loop

Errmsg = oexec. stderr. readall ()
Stdmsg = oexec. stdout. readall ()
If (oexec. exitcode = 0) Then 'cmderr: 1, phperr: 255, OK: 0
Desfromphpresult = stdmsg
End if
End Function
%>

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.