[ASP]Mettere in sicurezza codice invio ordine
Inviato: sabato 28 maggio 2016, 11:05
Premetto che non conosco ASP.
A un amico, che ha un vecchio sito statico su piattaforma Windows, bucano regolarmente il sito, inserendo pagine ASP e modificando le pagine html.
Come detto le pagine sono statiche, c'è un javascript presente in una sola pagina che serve per il precaricamento delle immagini e un javascript per i calcoli dell'importo.
Ho pensato che l'unico punto debole potesse essere il modulo d'ordine.
Googolando, non ho trovato pagine molto chiare sul problema sicurezza, ho aggiunto questo codice per ogni elemento 'Server.HTMLEncode(trim(Request.Form(...' sperando di migliorare la sicurezza.
Secondo voi questo codice è vulnerabile?
Se si, come metterlo in sicurezza?
Grazie per qualsiasi dritta.
A un amico, che ha un vecchio sito statico su piattaforma Windows, bucano regolarmente il sito, inserendo pagine ASP e modificando le pagine html.
Come detto le pagine sono statiche, c'è un javascript presente in una sola pagina che serve per il precaricamento delle immagini e un javascript per i calcoli dell'importo.
Ho pensato che l'unico punto debole potesse essere il modulo d'ordine.
Googolando, non ho trovato pagine molto chiare sul problema sicurezza, ho aggiunto questo codice per ogni elemento 'Server.HTMLEncode(trim(Request.Form(...' sperando di migliorare la sicurezza.
Secondo voi questo codice è vulnerabile?
Se si, come metterlo in sicurezza?
Grazie per qualsiasi dritta.
Codice: Seleziona tutto
<%@ Language=VBScript %>
<%
' provo i campi obbligatori
If ((trim(Request.Form("nome")) = "") Or (trim(Request.Form("cognome") = "")) Or (trim(Request.Form("email") = ""))) Then
Response.Redirect ("/frame-page-error.htm")
else
strNome = Server.HTMLEncode(trim(Request.Form("nome")))
strCognome = Server.HTMLEncode(trim(Request.Form("cognome")))
strVia = Server.HTMLEncode(trim(Request.Form("via/piazza")))
strNumCivico = Server.HTMLEncode(trim(Request.Form("numero civico")))
strCAP = Server.HTMLEncode(trim(Request.Form("CAP.")))
strCity = Server.HTMLEncode(trim(Request.Form("city")))
strProvincia = Server.HTMLEncode(trim(Request.Form("Provincia")))
strTelefono = Server.HTMLEncode(trim(Request.Form("telefono")))
strEmail = Server.HTMLEncode(trim(Request.Form("email")))
strPiva = Server.HTMLEncode(trim(Request.Form("partita IVA")))
strPagamento = Server.HTMLEncode(trim(Request.Form("pagamento")))
strCod_art_1 = Server.HTMLEncode(trim(Request.Form("cod_art_1")))
strCod_art_2 = Server.HTMLEncode(trim(Request.Form("cod_art_2")))
strCod_art_3 = Server.HTMLEncode(trim(Request.Form("cod_art_3")))
strCod_art_4 = Server.HTMLEncode(trim(Request.Form("cod_art_4")))
strCod_art_5 = Server.HTMLEncode(trim(Request.Form("cod_art_5")))
strCod_art_6 = Server.HTMLEncode(trim(Request.Form("cod_art_6")))
strDesc_art_1 = Server.HTMLEncode(trim(Request.Form("desc_art_1")))
strDesc_art_2 = Server.HTMLEncode(trim(Request.Form("desc_art_2")))
strDesc_art_3 = Server.HTMLEncode(trim(Request.Form("desc_art_3")))
strDesc_art_4 = Server.HTMLEncode(trim(Request.Form("desc_art_4")))
strDesc_art_5 = Server.HTMLEncode(trim(Request.Form("desc_art_5")))
strDesc_art_6 = Server.HTMLEncode(trim(Request.Form("desc_art_6")))
strPezzi_art_1 = Server.HTMLEncode(trim(Request.Form("pezzi_art_1")))
strPezzi_art_2 = Server.HTMLEncode(trim(Request.Form("pezzi_art_2")))
strPezzi_art_3 = Server.HTMLEncode(trim(Request.Form("pezzi_art_3")))
strPezzi_art_4 = Server.HTMLEncode(trim(Request.Form("pezzi_art_4")))
strPezzi_art_5 = Server.HTMLEncode(trim(Request.Form("pezzi_art_5")))
strPezzi_art_6 = Server.HTMLEncode(trim(Request.Form("pezzi_art_6")))
strImp_unit_art_1 = Server.HTMLEncode(trim(Request.Form("imp_unit_art_1")))
strImp_unit_art_2 = Server.HTMLEncode(trim(Request.Form("imp_unit_art_2")))
strImp_unit_art_3 = Server.HTMLEncode(trim(Request.Form("imp_unit_art_3")))
strImp_unit_art_4 = Server.HTMLEncode(trim(Request.Form("imp_unit_art_4")))
strImp_unit_art_5 = Server.HTMLEncode(trim(Request.Form("imp_unit_art_5")))
strImp_unit_art_6 = Server.HTMLEncode(trim(Request.Form("imp_unit_art_6")))
strImp_tot_art_1 = Server.HTMLEncode(trim(Request.Form("imp_tot_art_1")))
strImp_tot_art_2 = Server.HTMLEncode(trim(Request.Form("imp_tot_art_2")))
strImp_tot_art_3 = Server.HTMLEncode(trim(Request.Form("imp_tot_art_3")))
strImp_tot_art_4 = Server.HTMLEncode(trim(Request.Form("imp_tot_art_4")))
strImp_tot_art_5 = Server.HTMLEncode(trim(Request.Form("imp_tot_art_5")))
strImp_tot_art_6 = Server.HTMLEncode(trim(Request.Form("imp_tot_art_6")))
strTotale_merce = Server.HTMLEncode(trim(Request.Form("totale_merce")))
strSpese_spedizione = "16.00"
strTotale_ordine = Server.HTMLEncode(trim(Request.Form("totale_ordine")))
strDatiUtente = "<b>Dati Utente:</b><br><br>" & vbcrlf & strNome & " " & strCognome & "<br>" & vbcrlf & strVia & " n." & strNumCivico & "<br>" & vbcrlf & strCity & " - " & strCAP & " (" & strProvincia & ")<br>" & vbcrlf & "Tel: " & strTelefono & "<br>" & vbcrlf & "<a href=""mailto:" & strEmail & """>" & strEmail & "</a><br>" & vbcrlf & "P.iva: " & strPiva & "<br><br>" & vbcrlf
body = "<b><i>Non rispondere a questa email! Per le comunicazioni scrivere a <a href=""mailto:xxx@xxxx.it"">xxx@xxxx.it</a> o telefonare al numero 123456789 </i></b><hr width=""50%"" align=""center""><br><br>" & vbcrlf
body = body & "Ordine inviato da (nome cognome, email): <b>" & strNome & " " & strCognome & " , " &"<a href=""mailto:" & strEmail & """>" & strEmail & "</a></b> alle ore " & FormatDateTime(Now(),vbShortTime) & " del " & Date() & "<br><br>" & vbcrlf
body = body & "<b>Articolo 1 : </b><br>Codice: <b>" & strCod_art_1 & "</b> - Descrizione: <b>" & strDesc_art_1 & "</b><br>" & vbcrlf & "Quantità: <b>" & strPezzi_art_1 & "</b> - Costo Unitario :<b> € " & strImp_unit_art_1 & "</b> ----> Totale: <b>€ " & strImp_tot_art_1 & " </b><br><br>" & vbcrlf
body = body & "<b>Articolo 2 : </b><br>Codice: <b>" & strCod_art_2 & "</b> - Descrizione: <b>" & strDesc_art_2 & "</b><br>" & vbcrlf & "Quantità: <b>" & strPezzi_art_2 & "</b> - Costo Unitario :<b> € " & strImp_unit_art_2 & "</b> ----> Totale: <b>€ " & strImp_tot_art_2 & " </b><br><br>" & vbcrlf
body = body & "<b>Articolo 3 : </b><br>Codice: <b>" & strCod_art_3 & "</b> - Descrizione: <b>" & strDesc_art_3 & "</b><br>" & vbcrlf & "Quantità: <b>" & strPezzi_art_3 & "</b> - Costo Unitario :<b> € " & strImp_unit_art_3 & "</b> ----> Totale: <b>€ " & strImp_tot_art_3 & " </b><br><br>" & vbcrlf
body = body & "<b>Articolo 4 : </b><br>Codice: <b>" & strCod_art_4 & "</b> - Descrizione: <b>" & strDesc_art_4 & "</b><br>" & vbcrlf & "Quantità: <b>" & strPezzi_art_4 & "</b> - Costo Unitario :<b> € " & strImp_unit_art_4 & "</b> ----> Totale: <b>€ " & strImp_tot_art_4 & " </b><br><br>" & vbcrlf
body = body & "<b>Articolo 5 : </b><br>Codice: <b>" & strCod_art_5 & "</b> - Descrizione: <b>" & strDesc_art_5 & "</b><br>" & vbcrlf & "Quantità: <b>" & strPezzi_art_5 & "</b> - Costo Unitario :<b> € " & strImp_unit_art_5 & "</b> ----> Totale: <b>€ " & strImp_tot_art_5 & " </b><br><br>" & vbcrlf
body = body & "<b>Articolo 6 : </b><br>Codice: <b>" & strCod_art_6 & "</b> - Descrizione: <b>" & strDesc_art_6 & "</b><br>" & vbcrlf & "Quantità: <b>" & strPezzi_art_6 & "</b> - Costo Unitario :<b> € " & strImp_unit_art_6 & "</b> ----> Totale: <b>€ " & strImp_tot_art_6 & " </b><br><br>" & vbcrlf
body = body & "Totale merce<b>: € " & strTotale_merce & "</b> - Spese di Spedizione:<b>€ " & strSpese_spedizione & "</b> ----> Totale Ordine: <b>€ " & strTotale_ordine & " </b><br><br>" & vbcrlf
body = body & "Modalità di pagamento:<b> " & strPagamento & "</b><br><br>" & vbcrlf
body = body & strDatiUtente & "<br><br>" & vbcrlf
body = body & "<b><i>Grazie per aver effettuato l'ordine.</i></b><br><br>" & vbcrlf
End If
'For each sRequest in Request.Form
' If ((sRequest <> "subject") And (sRequest <> "nome") And (sRequest <> "cognome") And (sRequest <> "email") And (sRequest <> "via/piazza") And (sRequest <> "numero civico") And (sRequest <> "CAP.") And (sRequest <> "city") And (sRequest <> "Provincia") And (sRequest <> "telefono") And (sRequest <> "partita IVA") And (sRequest <> "email_to") And (sRequest <> "email_from") And (sRequest <> "email_bcc") And (sRequest <> "redirect") And (sRequest <> "pagamento") And (sRequest <> "Invia ordine")) Then
' If ((trim(Request.Form(sRequest)) <> "") And (trim(Request.Form(sRequest)) <> "0")) Then
' body = body & vbcrlf & sRequest & ": <b>" & Request.Form(sRequest)&"</b><br><br>" & vbcrlf
' End If
' End If
'Next
'invio email
Set objMail = Server.CreateObject("CDONTS.NewMail")
body = "<html><font face=arial size=2>"+body+"</font></html>"
objMail.BodyFormat = 0
objMail.MailFormat = 0
objMail.To = Request("email_to") & ";" & Request("email")
objMail.From = Request("email_from")
objMail.Bcc = Request("email_bcc")
objMail.Subject = Request("subject")
objMail.Body = body
objMail.importance = 2
objMail.Send
Set objMail = nothing
Response.Redirect (Request("redirect"))
%>