From ae4729b142ea36466d5ec8996199e6093fbcda23 Mon Sep 17 00:00:00 2001 From: Joren Date: Tue, 10 Nov 2026 02:16:11 +0100 Subject: [PATCH] Initial commit: obfuscator script with original and obfuscated sample sets --- .gitignore | 4 ++ Samples/BenchmarkTest00002.py | 65 ++++++++++++++++++ Samples/BenchmarkTest00007.py | 73 ++++++++++++++++++++ Samples/BenchmarkTest00014.py | 72 ++++++++++++++++++++ Samples/BenchmarkTest00015.py | 72 ++++++++++++++++++++ Samples/BenchmarkTest00024.py | 77 ++++++++++++++++++++++ Samples/BenchmarkTest00040.py | 67 +++++++++++++++++++ Samples/BenchmarkTest00044.py | 65 ++++++++++++++++++ Samples/BenchmarkTest00052.py | 70 ++++++++++++++++++++ Samples/BenchmarkTest00055.py | 72 ++++++++++++++++++++ Samples/BenchmarkTest00062.py | 74 +++++++++++++++++++++ Samples/BenchmarkTest00065.py | 69 +++++++++++++++++++ Samples/BenchmarkTest00066.py | 69 +++++++++++++++++++ Samples/BenchmarkTest00089.py | 52 +++++++++++++++ Samples/BenchmarkTest00094.py | 63 ++++++++++++++++++ Samples/BenchmarkTest00097.py | 46 +++++++++++++ Samples/BenchmarkTest00111.py | 60 +++++++++++++++++ Samples/BenchmarkTest00115.py | 59 +++++++++++++++++ Samples/BenchmarkTest00119.py | 68 +++++++++++++++++++ Samples/BenchmarkTest00121.py | 65 ++++++++++++++++++ Samples/BenchmarkTest00125.py | 59 +++++++++++++++++ Samples/BenchmarkTest00131.py | 57 ++++++++++++++++ Samples/BenchmarkTest00132.py | 58 ++++++++++++++++ Samples/BenchmarkTest00136.py | 64 ++++++++++++++++++ Samples/BenchmarkTest00139.py | 64 ++++++++++++++++++ Samples/BenchmarkTest00142.py | 70 ++++++++++++++++++++ Samples/BenchmarkTest00143.py | 66 +++++++++++++++++++ Samples/BenchmarkTest00146.py | 64 ++++++++++++++++++ Samples/BenchmarkTest00147.py | 64 ++++++++++++++++++ Samples/BenchmarkTest00162.py | 62 +++++++++++++++++ Samples/BenchmarkTest00164.py | 59 +++++++++++++++++ Samples/BenchmarkTest00176.py | 70 ++++++++++++++++++++ Samples/BenchmarkTest00179.py | 55 ++++++++++++++++ Samples/BenchmarkTest00187.py | 47 +++++++++++++ Samples/BenchmarkTest00190.py | 47 +++++++++++++ Samples/BenchmarkTest00192.py | 61 +++++++++++++++++ Samples/BenchmarkTest00194.py | 64 ++++++++++++++++++ Samples/BenchmarkTest00199.py | 59 +++++++++++++++++ Samples/BenchmarkTest00202.py | 61 +++++++++++++++++ Samples/BenchmarkTest00207.py | 70 ++++++++++++++++++++ Samples/BenchmarkTest00210.py | 64 ++++++++++++++++++ Samples/BenchmarkTest00218.py | 69 +++++++++++++++++++ Samples/BenchmarkTest00224.py | 58 ++++++++++++++++ Samples/BenchmarkTest00225.py | 65 ++++++++++++++++++ Samples/BenchmarkTest00229.py | 60 +++++++++++++++++ Samples/BenchmarkTest00230.py | 58 ++++++++++++++++ Samples/BenchmarkTest00235.py | 61 +++++++++++++++++ Samples/BenchmarkTest00248.py | 72 ++++++++++++++++++++ Samples/BenchmarkTest00256.py | 52 +++++++++++++++ Samples/BenchmarkTest00258.py | 43 ++++++++++++ Samples/BenchmarkTest00263.py | 59 +++++++++++++++++ Samples/BenchmarkTest00271.py | 63 ++++++++++++++++++ Samples/BenchmarkTest00284.py | 54 +++++++++++++++ Samples/BenchmarkTest00286.py | 59 +++++++++++++++++ Samples/BenchmarkTest00293.py | 69 +++++++++++++++++++ Samples/BenchmarkTest00314.py | 65 ++++++++++++++++++ Samples/BenchmarkTest00319.py | 68 +++++++++++++++++++ Samples/BenchmarkTest00324.py | 67 +++++++++++++++++++ Samples/BenchmarkTest00327.py | 74 +++++++++++++++++++++ Samples/BenchmarkTest00328.py | 67 +++++++++++++++++++ Samples/BenchmarkTest00331.py | 68 +++++++++++++++++++ Samples/BenchmarkTest00334.py | 53 +++++++++++++++ Samples/BenchmarkTest00335.py | 54 +++++++++++++++ Samples/BenchmarkTest00339.py | 55 ++++++++++++++++ Samples/BenchmarkTest00351.py | 59 +++++++++++++++++ Samples/BenchmarkTest00366.py | 50 ++++++++++++++ Samples/BenchmarkTest00390.py | 62 +++++++++++++++++ Samples/BenchmarkTest00394.py | 71 ++++++++++++++++++++ Samples/BenchmarkTest00408.py | 61 +++++++++++++++++ Samples/BenchmarkTest00412.py | 73 ++++++++++++++++++++ Samples/BenchmarkTest00430.py | 70 ++++++++++++++++++++ Samples/BenchmarkTest00433.py | 57 ++++++++++++++++ Samples/BenchmarkTest00434.py | 56 ++++++++++++++++ Samples/BenchmarkTest00436.py | 50 ++++++++++++++ Samples/BenchmarkTest00439.py | 65 ++++++++++++++++++ Samples/BenchmarkTest00441.py | 60 +++++++++++++++++ Samples/BenchmarkTest00448.py | 68 +++++++++++++++++++ Samples/BenchmarkTest00450.py | 46 +++++++++++++ Samples/BenchmarkTest00452.py | 48 ++++++++++++++ Samples/BenchmarkTest00458.py | 66 +++++++++++++++++++ Samples/BenchmarkTest00461.py | 71 ++++++++++++++++++++ Samples/BenchmarkTest00467.py | 63 ++++++++++++++++++ Samples/BenchmarkTest00469.py | 60 +++++++++++++++++ Samples/BenchmarkTest00470.py | 69 +++++++++++++++++++ Samples/BenchmarkTest00472.py | 67 +++++++++++++++++++ Samples/BenchmarkTest00477.py | 62 +++++++++++++++++ Samples/BenchmarkTest00488.py | 71 ++++++++++++++++++++ Samples/BenchmarkTest00491.py | 70 ++++++++++++++++++++ Samples/BenchmarkTest00494.py | 63 ++++++++++++++++++ Samples/BenchmarkTest00498.py | 54 +++++++++++++++ Samples/BenchmarkTest00502.py | 47 +++++++++++++ Samples/BenchmarkTest00506.py | 72 ++++++++++++++++++++ Samples/BenchmarkTest00508.py | 67 +++++++++++++++++++ Samples/BenchmarkTest00515.py | 47 +++++++++++++ Samples/BenchmarkTest00539.py | 69 +++++++++++++++++++ Samples/BenchmarkTest00540.py | 78 ++++++++++++++++++++++ Samples/BenchmarkTest00542.py | 66 +++++++++++++++++++ Samples/BenchmarkTest00543.py | 63 ++++++++++++++++++ Samples/BenchmarkTest00547.py | 68 +++++++++++++++++++ Samples/BenchmarkTest00549.py | 66 +++++++++++++++++++ Samples/BenchmarkTest00553.py | 64 ++++++++++++++++++ Samples/BenchmarkTest00564.py | 59 +++++++++++++++++ Samples/BenchmarkTest00570.py | 60 +++++++++++++++++ Samples/BenchmarkTest00571.py | 61 +++++++++++++++++ Samples/BenchmarkTest00593.py | 66 +++++++++++++++++++ Samples/BenchmarkTest00601.py | 52 +++++++++++++++ Samples/BenchmarkTest00602.py | 54 +++++++++++++++ Samples/BenchmarkTest00612.py | 67 +++++++++++++++++++ Samples/BenchmarkTest00630.py | 69 +++++++++++++++++++ Samples/BenchmarkTest00639.py | 65 ++++++++++++++++++ Samples/BenchmarkTest00645.py | 74 +++++++++++++++++++++ Samples/BenchmarkTest00647.py | 73 ++++++++++++++++++++ Samples/BenchmarkTest00664.py | 68 +++++++++++++++++++ Samples/BenchmarkTest00665.py | 60 +++++++++++++++++ Samples/BenchmarkTest00677.py | 61 +++++++++++++++++ Samples/BenchmarkTest00690.py | 64 ++++++++++++++++++ Samples/BenchmarkTest00693.py | 59 +++++++++++++++++ Samples/BenchmarkTest00695.py | 58 ++++++++++++++++ Samples/BenchmarkTest00697.py | 60 +++++++++++++++++ Samples/BenchmarkTest00705.py | 59 +++++++++++++++++ Samples/BenchmarkTest00726.py | 49 ++++++++++++++ Samples/BenchmarkTest00728.py | 58 ++++++++++++++++ Samples/BenchmarkTest00736.py | 66 +++++++++++++++++++ Samples/BenchmarkTest00741.py | 61 +++++++++++++++++ Samples/BenchmarkTest00742.py | 56 ++++++++++++++++ Samples/BenchmarkTest00744.py | 58 ++++++++++++++++ Samples/BenchmarkTest00748.py | 64 ++++++++++++++++++ Samples/BenchmarkTest00759.py | 73 ++++++++++++++++++++ Samples/BenchmarkTest00765.py | 59 +++++++++++++++++ Samples/BenchmarkTest00766.py | 65 ++++++++++++++++++ Samples/BenchmarkTest00776.py | 61 +++++++++++++++++ Samples/BenchmarkTest00778.py | 65 ++++++++++++++++++ Samples/BenchmarkTest00779.py | 61 +++++++++++++++++ Samples/BenchmarkTest00782.py | 61 +++++++++++++++++ Samples/BenchmarkTest00789.py | 66 +++++++++++++++++++ Samples/BenchmarkTest00811.py | 64 ++++++++++++++++++ Samples/BenchmarkTest00818.py | 57 ++++++++++++++++ Samples/BenchmarkTest00822.py | 54 +++++++++++++++ Samples/BenchmarkTest00825.py | 59 +++++++++++++++++ Samples/BenchmarkTest00834.py | 53 +++++++++++++++ Samples/BenchmarkTest00842.py | 49 ++++++++++++++ Samples/BenchmarkTest00860.py | 61 +++++++++++++++++ Samples/BenchmarkTest00865.py | 68 +++++++++++++++++++ Samples/BenchmarkTest00866.py | 64 ++++++++++++++++++ Samples/BenchmarkTest00867.py | 61 +++++++++++++++++ Samples/BenchmarkTest00868.py | 64 ++++++++++++++++++ Samples/BenchmarkTest00878.py | 74 +++++++++++++++++++++ Samples/BenchmarkTest00883.py | 56 ++++++++++++++++ Samples/BenchmarkTest00891.py | 57 ++++++++++++++++ Samples/BenchmarkTest00898.py | 61 +++++++++++++++++ Samples/BenchmarkTest00920.py | 70 ++++++++++++++++++++ Samples/BenchmarkTest00925.py | 60 +++++++++++++++++ Samples/BenchmarkTest00929.py | 84 ++++++++++++++++++++++++ Samples/BenchmarkTest00930.py | 76 +++++++++++++++++++++ Samples/BenchmarkTest00940.py | 73 ++++++++++++++++++++ Samples/BenchmarkTest00941.py | 74 +++++++++++++++++++++ Samples/BenchmarkTest00947.py | 68 +++++++++++++++++++ Samples/BenchmarkTest00957.py | 72 ++++++++++++++++++++ Samples/BenchmarkTest00959.py | 71 ++++++++++++++++++++ Samples/BenchmarkTest00969.py | 66 +++++++++++++++++++ Samples/BenchmarkTest00974.py | 74 +++++++++++++++++++++ Samples/BenchmarkTest00995.py | 62 +++++++++++++++++ Samples/BenchmarkTest00996.py | 66 +++++++++++++++++++ Samples/BenchmarkTest01001.py | 51 ++++++++++++++ Samples/BenchmarkTest01011.py | 69 +++++++++++++++++++ Samples/BenchmarkTest01023.py | 70 ++++++++++++++++++++ Samples/BenchmarkTest01026.py | 61 +++++++++++++++++ Samples/BenchmarkTest01035.py | 62 +++++++++++++++++ Samples/BenchmarkTest01040.py | 59 +++++++++++++++++ Samples/BenchmarkTest01044.py | 66 +++++++++++++++++++ Samples/BenchmarkTest01053.py | 66 +++++++++++++++++++ Samples/BenchmarkTest01060.py | 62 +++++++++++++++++ Samples/BenchmarkTest01081.py | 68 +++++++++++++++++++ Samples/BenchmarkTest01084.py | 48 ++++++++++++++ Samples/BenchmarkTest01087.py | 64 ++++++++++++++++++ Samples/BenchmarkTest01091.py | 60 +++++++++++++++++ Samples/BenchmarkTest01094.py | 49 ++++++++++++++ Samples/BenchmarkTest01099.py | 58 ++++++++++++++++ Samples/BenchmarkTest01100.py | 59 +++++++++++++++++ Samples/BenchmarkTest01104.py | 46 +++++++++++++ Samples/BenchmarkTest01105.py | 68 +++++++++++++++++++ Samples/BenchmarkTest01117.py | 64 ++++++++++++++++++ Samples/BenchmarkTest01126.py | 64 ++++++++++++++++++ Samples/BenchmarkTest01131.py | 60 +++++++++++++++++ Samples/BenchmarkTest01134.py | 60 +++++++++++++++++ Samples/BenchmarkTest01135.py | 58 ++++++++++++++++ Samples/BenchmarkTest01141.py | 65 ++++++++++++++++++ Samples/BenchmarkTest01150.py | 70 ++++++++++++++++++++ Samples/BenchmarkTest01162.py | 47 +++++++++++++ Samples/BenchmarkTest01170.py | 76 +++++++++++++++++++++ Samples/BenchmarkTest01181.py | 47 +++++++++++++ Samples/BenchmarkTest01183.py | 57 ++++++++++++++++ Samples/BenchmarkTest01196.py | 52 +++++++++++++++ Samples/BenchmarkTest01198.py | 66 +++++++++++++++++++ Samples/BenchmarkTest01205.py | 57 ++++++++++++++++ Samples/BenchmarkTest01206.py | 64 ++++++++++++++++++ Samples/BenchmarkTest01207.py | 61 +++++++++++++++++ Samples/BenchmarkTest01210.py | 45 +++++++++++++ Samples/BenchmarkTest01221.py | 69 +++++++++++++++++++ Samples/BenchmarkTest01222.py | 59 +++++++++++++++++ Samples/BenchmarkTest01227.py | 65 ++++++++++++++++++ Samples_Obfuscated/BenchmarkTest00002.py | 29 ++++++++ Samples_Obfuscated/BenchmarkTest00007.py | 38 +++++++++++ Samples_Obfuscated/BenchmarkTest00014.py | 37 +++++++++++ Samples_Obfuscated/BenchmarkTest00015.py | 37 +++++++++++ Samples_Obfuscated/BenchmarkTest00024.py | 43 ++++++++++++ Samples_Obfuscated/BenchmarkTest00040.py | 34 ++++++++++ Samples_Obfuscated/BenchmarkTest00044.py | 32 +++++++++ Samples_Obfuscated/BenchmarkTest00052.py | 37 +++++++++++ Samples_Obfuscated/BenchmarkTest00055.py | 37 +++++++++++ Samples_Obfuscated/BenchmarkTest00062.py | 40 +++++++++++ Samples_Obfuscated/BenchmarkTest00065.py | 33 ++++++++++ Samples_Obfuscated/BenchmarkTest00066.py | 34 ++++++++++ Samples_Obfuscated/BenchmarkTest00089.py | 29 ++++++++ Samples_Obfuscated/BenchmarkTest00094.py | 29 ++++++++ Samples_Obfuscated/BenchmarkTest00097.py | 21 ++++++ Samples_Obfuscated/BenchmarkTest00111.py | 32 +++++++++ Samples_Obfuscated/BenchmarkTest00115.py | 30 +++++++++ Samples_Obfuscated/BenchmarkTest00119.py | 38 +++++++++++ Samples_Obfuscated/BenchmarkTest00121.py | 35 ++++++++++ Samples_Obfuscated/BenchmarkTest00125.py | 30 +++++++++ Samples_Obfuscated/BenchmarkTest00131.py | 28 ++++++++ Samples_Obfuscated/BenchmarkTest00132.py | 29 ++++++++ Samples_Obfuscated/BenchmarkTest00136.py | 35 ++++++++++ Samples_Obfuscated/BenchmarkTest00139.py | 35 ++++++++++ Samples_Obfuscated/BenchmarkTest00142.py | 40 +++++++++++ Samples_Obfuscated/BenchmarkTest00143.py | 35 ++++++++++ Samples_Obfuscated/BenchmarkTest00146.py | 34 ++++++++++ Samples_Obfuscated/BenchmarkTest00147.py | 34 ++++++++++ Samples_Obfuscated/BenchmarkTest00162.py | 34 ++++++++++ Samples_Obfuscated/BenchmarkTest00164.py | 30 +++++++++ Samples_Obfuscated/BenchmarkTest00176.py | 41 ++++++++++++ Samples_Obfuscated/BenchmarkTest00179.py | 32 +++++++++ Samples_Obfuscated/BenchmarkTest00187.py | 22 +++++++ Samples_Obfuscated/BenchmarkTest00190.py | 21 ++++++ Samples_Obfuscated/BenchmarkTest00192.py | 35 ++++++++++ Samples_Obfuscated/BenchmarkTest00194.py | 35 ++++++++++ Samples_Obfuscated/BenchmarkTest00199.py | 30 +++++++++ Samples_Obfuscated/BenchmarkTest00202.py | 31 +++++++++ Samples_Obfuscated/BenchmarkTest00207.py | 41 ++++++++++++ Samples_Obfuscated/BenchmarkTest00210.py | 35 ++++++++++ Samples_Obfuscated/BenchmarkTest00218.py | 39 +++++++++++ Samples_Obfuscated/BenchmarkTest00224.py | 29 ++++++++ Samples_Obfuscated/BenchmarkTest00225.py | 35 ++++++++++ Samples_Obfuscated/BenchmarkTest00229.py | 31 +++++++++ Samples_Obfuscated/BenchmarkTest00230.py | 29 ++++++++ Samples_Obfuscated/BenchmarkTest00235.py | 32 +++++++++ Samples_Obfuscated/BenchmarkTest00248.py | 41 ++++++++++++ Samples_Obfuscated/BenchmarkTest00256.py | 24 +++++++ Samples_Obfuscated/BenchmarkTest00258.py | 20 ++++++ Samples_Obfuscated/BenchmarkTest00263.py | 32 +++++++++ Samples_Obfuscated/BenchmarkTest00271.py | 34 ++++++++++ Samples_Obfuscated/BenchmarkTest00284.py | 28 ++++++++ Samples_Obfuscated/BenchmarkTest00286.py | 32 +++++++++ Samples_Obfuscated/BenchmarkTest00293.py | 36 ++++++++++ Samples_Obfuscated/BenchmarkTest00314.py | 34 ++++++++++ Samples_Obfuscated/BenchmarkTest00319.py | 37 +++++++++++ Samples_Obfuscated/BenchmarkTest00324.py | 36 ++++++++++ Samples_Obfuscated/BenchmarkTest00327.py | 42 ++++++++++++ Samples_Obfuscated/BenchmarkTest00328.py | 36 ++++++++++ Samples_Obfuscated/BenchmarkTest00331.py | 37 +++++++++++ Samples_Obfuscated/BenchmarkTest00334.py | 25 +++++++ Samples_Obfuscated/BenchmarkTest00335.py | 25 +++++++ Samples_Obfuscated/BenchmarkTest00339.py | 26 ++++++++ Samples_Obfuscated/BenchmarkTest00351.py | 27 ++++++++ Samples_Obfuscated/BenchmarkTest00366.py | 25 +++++++ Samples_Obfuscated/BenchmarkTest00390.py | 32 +++++++++ Samples_Obfuscated/BenchmarkTest00394.py | 41 ++++++++++++ Samples_Obfuscated/BenchmarkTest00408.py | 31 +++++++++ Samples_Obfuscated/BenchmarkTest00412.py | 43 ++++++++++++ Samples_Obfuscated/BenchmarkTest00430.py | 38 +++++++++++ Samples_Obfuscated/BenchmarkTest00433.py | 29 ++++++++ Samples_Obfuscated/BenchmarkTest00434.py | 27 ++++++++ Samples_Obfuscated/BenchmarkTest00436.py | 25 +++++++ Samples_Obfuscated/BenchmarkTest00439.py | 35 ++++++++++ Samples_Obfuscated/BenchmarkTest00441.py | 31 +++++++++ Samples_Obfuscated/BenchmarkTest00448.py | 34 ++++++++++ Samples_Obfuscated/BenchmarkTest00450.py | 21 ++++++ Samples_Obfuscated/BenchmarkTest00452.py | 22 +++++++ Samples_Obfuscated/BenchmarkTest00458.py | 34 ++++++++++ Samples_Obfuscated/BenchmarkTest00461.py | 40 +++++++++++ Samples_Obfuscated/BenchmarkTest00467.py | 34 ++++++++++ Samples_Obfuscated/BenchmarkTest00469.py | 32 +++++++++ Samples_Obfuscated/BenchmarkTest00470.py | 40 +++++++++++ Samples_Obfuscated/BenchmarkTest00472.py | 37 +++++++++++ Samples_Obfuscated/BenchmarkTest00477.py | 32 +++++++++ Samples_Obfuscated/BenchmarkTest00488.py | 41 ++++++++++++ Samples_Obfuscated/BenchmarkTest00491.py | 40 +++++++++++ Samples_Obfuscated/BenchmarkTest00494.py | 32 +++++++++ Samples_Obfuscated/BenchmarkTest00498.py | 27 ++++++++ Samples_Obfuscated/BenchmarkTest00502.py | 20 ++++++ Samples_Obfuscated/BenchmarkTest00506.py | 39 +++++++++++ Samples_Obfuscated/BenchmarkTest00508.py | 37 +++++++++++ Samples_Obfuscated/BenchmarkTest00515.py | 20 ++++++ Samples_Obfuscated/BenchmarkTest00539.py | 37 +++++++++++ Samples_Obfuscated/BenchmarkTest00540.py | 45 +++++++++++++ Samples_Obfuscated/BenchmarkTest00542.py | 37 +++++++++++ Samples_Obfuscated/BenchmarkTest00543.py | 33 ++++++++++ Samples_Obfuscated/BenchmarkTest00547.py | 38 +++++++++++ Samples_Obfuscated/BenchmarkTest00549.py | 34 ++++++++++ Samples_Obfuscated/BenchmarkTest00553.py | 35 ++++++++++ Samples_Obfuscated/BenchmarkTest00564.py | 29 ++++++++ Samples_Obfuscated/BenchmarkTest00570.py | 30 +++++++++ Samples_Obfuscated/BenchmarkTest00571.py | 31 +++++++++ Samples_Obfuscated/BenchmarkTest00593.py | 33 ++++++++++ Samples_Obfuscated/BenchmarkTest00601.py | 24 +++++++ Samples_Obfuscated/BenchmarkTest00602.py | 28 ++++++++ Samples_Obfuscated/BenchmarkTest00612.py | 32 +++++++++ Samples_Obfuscated/BenchmarkTest00630.py | 37 +++++++++++ Samples_Obfuscated/BenchmarkTest00639.py | 34 ++++++++++ Samples_Obfuscated/BenchmarkTest00645.py | 41 ++++++++++++ Samples_Obfuscated/BenchmarkTest00647.py | 41 ++++++++++++ Samples_Obfuscated/BenchmarkTest00664.py | 34 ++++++++++ Samples_Obfuscated/BenchmarkTest00665.py | 30 +++++++++ Samples_Obfuscated/BenchmarkTest00677.py | 31 +++++++++ Samples_Obfuscated/BenchmarkTest00690.py | 35 ++++++++++ Samples_Obfuscated/BenchmarkTest00693.py | 30 +++++++++ Samples_Obfuscated/BenchmarkTest00695.py | 29 ++++++++ Samples_Obfuscated/BenchmarkTest00697.py | 31 +++++++++ Samples_Obfuscated/BenchmarkTest00705.py | 29 ++++++++ Samples_Obfuscated/BenchmarkTest00726.py | 21 ++++++ Samples_Obfuscated/BenchmarkTest00728.py | 31 +++++++++ Samples_Obfuscated/BenchmarkTest00736.py | 37 +++++++++++ Samples_Obfuscated/BenchmarkTest00741.py | 32 +++++++++ Samples_Obfuscated/BenchmarkTest00742.py | 33 ++++++++++ Samples_Obfuscated/BenchmarkTest00744.py | 30 +++++++++ Samples_Obfuscated/BenchmarkTest00748.py | 30 +++++++++ Samples_Obfuscated/BenchmarkTest00759.py | 41 ++++++++++++ Samples_Obfuscated/BenchmarkTest00765.py | 30 +++++++++ Samples_Obfuscated/BenchmarkTest00766.py | 36 ++++++++++ Samples_Obfuscated/BenchmarkTest00776.py | 32 +++++++++ Samples_Obfuscated/BenchmarkTest00778.py | 36 ++++++++++ Samples_Obfuscated/BenchmarkTest00779.py | 31 +++++++++ Samples_Obfuscated/BenchmarkTest00782.py | 32 +++++++++ Samples_Obfuscated/BenchmarkTest00789.py | 37 +++++++++++ Samples_Obfuscated/BenchmarkTest00811.py | 33 ++++++++++ Samples_Obfuscated/BenchmarkTest00818.py | 27 ++++++++ Samples_Obfuscated/BenchmarkTest00822.py | 26 ++++++++ Samples_Obfuscated/BenchmarkTest00825.py | 30 +++++++++ Samples_Obfuscated/BenchmarkTest00834.py | 28 ++++++++ Samples_Obfuscated/BenchmarkTest00842.py | 22 +++++++ Samples_Obfuscated/BenchmarkTest00860.py | 31 +++++++++ Samples_Obfuscated/BenchmarkTest00865.py | 38 +++++++++++ Samples_Obfuscated/BenchmarkTest00866.py | 34 ++++++++++ Samples_Obfuscated/BenchmarkTest00867.py | 31 +++++++++ Samples_Obfuscated/BenchmarkTest00868.py | 34 ++++++++++ Samples_Obfuscated/BenchmarkTest00878.py | 43 ++++++++++++ Samples_Obfuscated/BenchmarkTest00883.py | 28 ++++++++ Samples_Obfuscated/BenchmarkTest00891.py | 29 ++++++++ Samples_Obfuscated/BenchmarkTest00898.py | 31 +++++++++ Samples_Obfuscated/BenchmarkTest00920.py | 38 +++++++++++ Samples_Obfuscated/BenchmarkTest00925.py | 32 +++++++++ Samples_Obfuscated/BenchmarkTest00929.py | 50 ++++++++++++++ Samples_Obfuscated/BenchmarkTest00930.py | 43 ++++++++++++ Samples_Obfuscated/BenchmarkTest00940.py | 43 ++++++++++++ Samples_Obfuscated/BenchmarkTest00941.py | 44 +++++++++++++ Samples_Obfuscated/BenchmarkTest00947.py | 37 +++++++++++ Samples_Obfuscated/BenchmarkTest00957.py | 40 +++++++++++ Samples_Obfuscated/BenchmarkTest00959.py | 40 +++++++++++ Samples_Obfuscated/BenchmarkTest00969.py | 35 ++++++++++ Samples_Obfuscated/BenchmarkTest00974.py | 42 ++++++++++++ Samples_Obfuscated/BenchmarkTest00995.py | 31 +++++++++ Samples_Obfuscated/BenchmarkTest00996.py | 36 ++++++++++ Samples_Obfuscated/BenchmarkTest01001.py | 26 ++++++++ Samples_Obfuscated/BenchmarkTest01011.py | 35 ++++++++++ Samples_Obfuscated/BenchmarkTest01023.py | 40 +++++++++++ Samples_Obfuscated/BenchmarkTest01026.py | 33 ++++++++++ Samples_Obfuscated/BenchmarkTest01035.py | 34 ++++++++++ Samples_Obfuscated/BenchmarkTest01040.py | 30 +++++++++ Samples_Obfuscated/BenchmarkTest01044.py | 37 +++++++++++ Samples_Obfuscated/BenchmarkTest01053.py | 36 ++++++++++ Samples_Obfuscated/BenchmarkTest01060.py | 32 +++++++++ Samples_Obfuscated/BenchmarkTest01081.py | 37 +++++++++++ Samples_Obfuscated/BenchmarkTest01084.py | 21 ++++++ Samples_Obfuscated/BenchmarkTest01087.py | 33 ++++++++++ Samples_Obfuscated/BenchmarkTest01091.py | 31 +++++++++ Samples_Obfuscated/BenchmarkTest01094.py | 22 +++++++ Samples_Obfuscated/BenchmarkTest01099.py | 30 +++++++++ Samples_Obfuscated/BenchmarkTest01100.py | 30 +++++++++ Samples_Obfuscated/BenchmarkTest01104.py | 20 ++++++ Samples_Obfuscated/BenchmarkTest01105.py | 38 +++++++++++ Samples_Obfuscated/BenchmarkTest01117.py | 35 ++++++++++ Samples_Obfuscated/BenchmarkTest01126.py | 35 ++++++++++ Samples_Obfuscated/BenchmarkTest01131.py | 31 +++++++++ Samples_Obfuscated/BenchmarkTest01134.py | 31 +++++++++ Samples_Obfuscated/BenchmarkTest01135.py | 29 ++++++++ Samples_Obfuscated/BenchmarkTest01141.py | 36 ++++++++++ Samples_Obfuscated/BenchmarkTest01150.py | 40 +++++++++++ Samples_Obfuscated/BenchmarkTest01162.py | 20 ++++++ Samples_Obfuscated/BenchmarkTest01170.py | 43 ++++++++++++ Samples_Obfuscated/BenchmarkTest01181.py | 23 +++++++ Samples_Obfuscated/BenchmarkTest01183.py | 26 ++++++++ Samples_Obfuscated/BenchmarkTest01196.py | 23 +++++++ Samples_Obfuscated/BenchmarkTest01198.py | 33 ++++++++++ Samples_Obfuscated/BenchmarkTest01205.py | 27 ++++++++ Samples_Obfuscated/BenchmarkTest01206.py | 33 ++++++++++ Samples_Obfuscated/BenchmarkTest01207.py | 29 ++++++++ Samples_Obfuscated/BenchmarkTest01210.py | 19 ++++++ Samples_Obfuscated/BenchmarkTest01221.py | 35 ++++++++++ Samples_Obfuscated/BenchmarkTest01222.py | 30 +++++++++ Samples_Obfuscated/BenchmarkTest01227.py | 34 ++++++++++ obfuscator.py | 50 ++++++++++++++ 402 files changed, 19099 insertions(+) create mode 100644 .gitignore create mode 100644 Samples/BenchmarkTest00002.py create mode 100644 Samples/BenchmarkTest00007.py create mode 100644 Samples/BenchmarkTest00014.py create mode 100644 Samples/BenchmarkTest00015.py create mode 100644 Samples/BenchmarkTest00024.py create mode 100644 Samples/BenchmarkTest00040.py create mode 100644 Samples/BenchmarkTest00044.py create mode 100644 Samples/BenchmarkTest00052.py create mode 100644 Samples/BenchmarkTest00055.py create mode 100644 Samples/BenchmarkTest00062.py create mode 100644 Samples/BenchmarkTest00065.py create mode 100644 Samples/BenchmarkTest00066.py create mode 100644 Samples/BenchmarkTest00089.py create mode 100644 Samples/BenchmarkTest00094.py create mode 100644 Samples/BenchmarkTest00097.py create mode 100644 Samples/BenchmarkTest00111.py create mode 100644 Samples/BenchmarkTest00115.py create mode 100644 Samples/BenchmarkTest00119.py create mode 100644 Samples/BenchmarkTest00121.py create mode 100644 Samples/BenchmarkTest00125.py create mode 100644 Samples/BenchmarkTest00131.py create mode 100644 Samples/BenchmarkTest00132.py create mode 100644 Samples/BenchmarkTest00136.py create mode 100644 Samples/BenchmarkTest00139.py create mode 100644 Samples/BenchmarkTest00142.py create mode 100644 Samples/BenchmarkTest00143.py create mode 100644 Samples/BenchmarkTest00146.py create mode 100644 Samples/BenchmarkTest00147.py create mode 100644 Samples/BenchmarkTest00162.py create mode 100644 Samples/BenchmarkTest00164.py create mode 100644 Samples/BenchmarkTest00176.py create mode 100644 Samples/BenchmarkTest00179.py create mode 100644 Samples/BenchmarkTest00187.py create mode 100644 Samples/BenchmarkTest00190.py create mode 100644 Samples/BenchmarkTest00192.py create mode 100644 Samples/BenchmarkTest00194.py create mode 100644 Samples/BenchmarkTest00199.py create mode 100644 Samples/BenchmarkTest00202.py create mode 100644 Samples/BenchmarkTest00207.py create mode 100644 Samples/BenchmarkTest00210.py create mode 100644 Samples/BenchmarkTest00218.py create mode 100644 Samples/BenchmarkTest00224.py create mode 100644 Samples/BenchmarkTest00225.py create mode 100644 Samples/BenchmarkTest00229.py create mode 100644 Samples/BenchmarkTest00230.py create mode 100644 Samples/BenchmarkTest00235.py create mode 100644 Samples/BenchmarkTest00248.py create mode 100644 Samples/BenchmarkTest00256.py create mode 100644 Samples/BenchmarkTest00258.py create mode 100644 Samples/BenchmarkTest00263.py create mode 100644 Samples/BenchmarkTest00271.py create mode 100644 Samples/BenchmarkTest00284.py create mode 100644 Samples/BenchmarkTest00286.py create mode 100644 Samples/BenchmarkTest00293.py create mode 100644 Samples/BenchmarkTest00314.py create mode 100644 Samples/BenchmarkTest00319.py create mode 100644 Samples/BenchmarkTest00324.py create mode 100644 Samples/BenchmarkTest00327.py create mode 100644 Samples/BenchmarkTest00328.py create mode 100644 Samples/BenchmarkTest00331.py create mode 100644 Samples/BenchmarkTest00334.py create mode 100644 Samples/BenchmarkTest00335.py create mode 100644 Samples/BenchmarkTest00339.py create mode 100644 Samples/BenchmarkTest00351.py create mode 100644 Samples/BenchmarkTest00366.py create mode 100644 Samples/BenchmarkTest00390.py create mode 100644 Samples/BenchmarkTest00394.py create mode 100644 Samples/BenchmarkTest00408.py create mode 100644 Samples/BenchmarkTest00412.py create mode 100644 Samples/BenchmarkTest00430.py create mode 100644 Samples/BenchmarkTest00433.py create mode 100644 Samples/BenchmarkTest00434.py create mode 100644 Samples/BenchmarkTest00436.py create mode 100644 Samples/BenchmarkTest00439.py create mode 100644 Samples/BenchmarkTest00441.py create mode 100644 Samples/BenchmarkTest00448.py create mode 100644 Samples/BenchmarkTest00450.py create mode 100644 Samples/BenchmarkTest00452.py create mode 100644 Samples/BenchmarkTest00458.py create mode 100644 Samples/BenchmarkTest00461.py create mode 100644 Samples/BenchmarkTest00467.py create mode 100644 Samples/BenchmarkTest00469.py create mode 100644 Samples/BenchmarkTest00470.py create mode 100644 Samples/BenchmarkTest00472.py create mode 100644 Samples/BenchmarkTest00477.py create mode 100644 Samples/BenchmarkTest00488.py create mode 100644 Samples/BenchmarkTest00491.py create mode 100644 Samples/BenchmarkTest00494.py create mode 100644 Samples/BenchmarkTest00498.py create mode 100644 Samples/BenchmarkTest00502.py create mode 100644 Samples/BenchmarkTest00506.py create mode 100644 Samples/BenchmarkTest00508.py create mode 100644 Samples/BenchmarkTest00515.py create mode 100644 Samples/BenchmarkTest00539.py create mode 100644 Samples/BenchmarkTest00540.py create mode 100644 Samples/BenchmarkTest00542.py create mode 100644 Samples/BenchmarkTest00543.py create mode 100644 Samples/BenchmarkTest00547.py create mode 100644 Samples/BenchmarkTest00549.py create mode 100644 Samples/BenchmarkTest00553.py create mode 100644 Samples/BenchmarkTest00564.py create mode 100644 Samples/BenchmarkTest00570.py create mode 100644 Samples/BenchmarkTest00571.py create mode 100644 Samples/BenchmarkTest00593.py create mode 100644 Samples/BenchmarkTest00601.py create mode 100644 Samples/BenchmarkTest00602.py create mode 100644 Samples/BenchmarkTest00612.py create mode 100644 Samples/BenchmarkTest00630.py create mode 100644 Samples/BenchmarkTest00639.py create mode 100644 Samples/BenchmarkTest00645.py create mode 100644 Samples/BenchmarkTest00647.py create mode 100644 Samples/BenchmarkTest00664.py create mode 100644 Samples/BenchmarkTest00665.py create mode 100644 Samples/BenchmarkTest00677.py create mode 100644 Samples/BenchmarkTest00690.py create mode 100644 Samples/BenchmarkTest00693.py create mode 100644 Samples/BenchmarkTest00695.py create mode 100644 Samples/BenchmarkTest00697.py create mode 100644 Samples/BenchmarkTest00705.py create mode 100644 Samples/BenchmarkTest00726.py create mode 100644 Samples/BenchmarkTest00728.py create mode 100644 Samples/BenchmarkTest00736.py create mode 100644 Samples/BenchmarkTest00741.py create mode 100644 Samples/BenchmarkTest00742.py create mode 100644 Samples/BenchmarkTest00744.py create mode 100644 Samples/BenchmarkTest00748.py create mode 100644 Samples/BenchmarkTest00759.py create mode 100644 Samples/BenchmarkTest00765.py create mode 100644 Samples/BenchmarkTest00766.py create mode 100644 Samples/BenchmarkTest00776.py create mode 100644 Samples/BenchmarkTest00778.py create mode 100644 Samples/BenchmarkTest00779.py create mode 100644 Samples/BenchmarkTest00782.py create mode 100644 Samples/BenchmarkTest00789.py create mode 100644 Samples/BenchmarkTest00811.py create mode 100644 Samples/BenchmarkTest00818.py create mode 100644 Samples/BenchmarkTest00822.py create mode 100644 Samples/BenchmarkTest00825.py create mode 100644 Samples/BenchmarkTest00834.py create mode 100644 Samples/BenchmarkTest00842.py create mode 100644 Samples/BenchmarkTest00860.py create mode 100644 Samples/BenchmarkTest00865.py create mode 100644 Samples/BenchmarkTest00866.py create mode 100644 Samples/BenchmarkTest00867.py create mode 100644 Samples/BenchmarkTest00868.py create mode 100644 Samples/BenchmarkTest00878.py create mode 100644 Samples/BenchmarkTest00883.py create mode 100644 Samples/BenchmarkTest00891.py create mode 100644 Samples/BenchmarkTest00898.py create mode 100644 Samples/BenchmarkTest00920.py create mode 100644 Samples/BenchmarkTest00925.py create mode 100644 Samples/BenchmarkTest00929.py create mode 100644 Samples/BenchmarkTest00930.py create mode 100644 Samples/BenchmarkTest00940.py create mode 100644 Samples/BenchmarkTest00941.py create mode 100644 Samples/BenchmarkTest00947.py create mode 100644 Samples/BenchmarkTest00957.py create mode 100644 Samples/BenchmarkTest00959.py create mode 100644 Samples/BenchmarkTest00969.py create mode 100644 Samples/BenchmarkTest00974.py create mode 100644 Samples/BenchmarkTest00995.py create mode 100644 Samples/BenchmarkTest00996.py create mode 100644 Samples/BenchmarkTest01001.py create mode 100644 Samples/BenchmarkTest01011.py create mode 100644 Samples/BenchmarkTest01023.py create mode 100644 Samples/BenchmarkTest01026.py create mode 100644 Samples/BenchmarkTest01035.py create mode 100644 Samples/BenchmarkTest01040.py create mode 100644 Samples/BenchmarkTest01044.py create mode 100644 Samples/BenchmarkTest01053.py create mode 100644 Samples/BenchmarkTest01060.py create mode 100644 Samples/BenchmarkTest01081.py create mode 100644 Samples/BenchmarkTest01084.py create mode 100644 Samples/BenchmarkTest01087.py create mode 100644 Samples/BenchmarkTest01091.py create mode 100644 Samples/BenchmarkTest01094.py create mode 100644 Samples/BenchmarkTest01099.py create mode 100644 Samples/BenchmarkTest01100.py create mode 100644 Samples/BenchmarkTest01104.py create mode 100644 Samples/BenchmarkTest01105.py create mode 100644 Samples/BenchmarkTest01117.py create mode 100644 Samples/BenchmarkTest01126.py create mode 100644 Samples/BenchmarkTest01131.py create mode 100644 Samples/BenchmarkTest01134.py create mode 100644 Samples/BenchmarkTest01135.py create mode 100644 Samples/BenchmarkTest01141.py create mode 100644 Samples/BenchmarkTest01150.py create mode 100644 Samples/BenchmarkTest01162.py create mode 100644 Samples/BenchmarkTest01170.py create mode 100644 Samples/BenchmarkTest01181.py create mode 100644 Samples/BenchmarkTest01183.py create mode 100644 Samples/BenchmarkTest01196.py create mode 100644 Samples/BenchmarkTest01198.py create mode 100644 Samples/BenchmarkTest01205.py create mode 100644 Samples/BenchmarkTest01206.py create mode 100644 Samples/BenchmarkTest01207.py create mode 100644 Samples/BenchmarkTest01210.py create mode 100644 Samples/BenchmarkTest01221.py create mode 100644 Samples/BenchmarkTest01222.py create mode 100644 Samples/BenchmarkTest01227.py create mode 100644 Samples_Obfuscated/BenchmarkTest00002.py create mode 100644 Samples_Obfuscated/BenchmarkTest00007.py create mode 100644 Samples_Obfuscated/BenchmarkTest00014.py create mode 100644 Samples_Obfuscated/BenchmarkTest00015.py create mode 100644 Samples_Obfuscated/BenchmarkTest00024.py create mode 100644 Samples_Obfuscated/BenchmarkTest00040.py create mode 100644 Samples_Obfuscated/BenchmarkTest00044.py create mode 100644 Samples_Obfuscated/BenchmarkTest00052.py create mode 100644 Samples_Obfuscated/BenchmarkTest00055.py create mode 100644 Samples_Obfuscated/BenchmarkTest00062.py create mode 100644 Samples_Obfuscated/BenchmarkTest00065.py create mode 100644 Samples_Obfuscated/BenchmarkTest00066.py create mode 100644 Samples_Obfuscated/BenchmarkTest00089.py create mode 100644 Samples_Obfuscated/BenchmarkTest00094.py create mode 100644 Samples_Obfuscated/BenchmarkTest00097.py create mode 100644 Samples_Obfuscated/BenchmarkTest00111.py create mode 100644 Samples_Obfuscated/BenchmarkTest00115.py create mode 100644 Samples_Obfuscated/BenchmarkTest00119.py create mode 100644 Samples_Obfuscated/BenchmarkTest00121.py create mode 100644 Samples_Obfuscated/BenchmarkTest00125.py create mode 100644 Samples_Obfuscated/BenchmarkTest00131.py create mode 100644 Samples_Obfuscated/BenchmarkTest00132.py create mode 100644 Samples_Obfuscated/BenchmarkTest00136.py create mode 100644 Samples_Obfuscated/BenchmarkTest00139.py create mode 100644 Samples_Obfuscated/BenchmarkTest00142.py create mode 100644 Samples_Obfuscated/BenchmarkTest00143.py create mode 100644 Samples_Obfuscated/BenchmarkTest00146.py create mode 100644 Samples_Obfuscated/BenchmarkTest00147.py create mode 100644 Samples_Obfuscated/BenchmarkTest00162.py create mode 100644 Samples_Obfuscated/BenchmarkTest00164.py create mode 100644 Samples_Obfuscated/BenchmarkTest00176.py create mode 100644 Samples_Obfuscated/BenchmarkTest00179.py create mode 100644 Samples_Obfuscated/BenchmarkTest00187.py create mode 100644 Samples_Obfuscated/BenchmarkTest00190.py create mode 100644 Samples_Obfuscated/BenchmarkTest00192.py create mode 100644 Samples_Obfuscated/BenchmarkTest00194.py create mode 100644 Samples_Obfuscated/BenchmarkTest00199.py create mode 100644 Samples_Obfuscated/BenchmarkTest00202.py create mode 100644 Samples_Obfuscated/BenchmarkTest00207.py create mode 100644 Samples_Obfuscated/BenchmarkTest00210.py create mode 100644 Samples_Obfuscated/BenchmarkTest00218.py create mode 100644 Samples_Obfuscated/BenchmarkTest00224.py create mode 100644 Samples_Obfuscated/BenchmarkTest00225.py create mode 100644 Samples_Obfuscated/BenchmarkTest00229.py create mode 100644 Samples_Obfuscated/BenchmarkTest00230.py create mode 100644 Samples_Obfuscated/BenchmarkTest00235.py create mode 100644 Samples_Obfuscated/BenchmarkTest00248.py create mode 100644 Samples_Obfuscated/BenchmarkTest00256.py create mode 100644 Samples_Obfuscated/BenchmarkTest00258.py create mode 100644 Samples_Obfuscated/BenchmarkTest00263.py create mode 100644 Samples_Obfuscated/BenchmarkTest00271.py create mode 100644 Samples_Obfuscated/BenchmarkTest00284.py create mode 100644 Samples_Obfuscated/BenchmarkTest00286.py create mode 100644 Samples_Obfuscated/BenchmarkTest00293.py create mode 100644 Samples_Obfuscated/BenchmarkTest00314.py create mode 100644 Samples_Obfuscated/BenchmarkTest00319.py create mode 100644 Samples_Obfuscated/BenchmarkTest00324.py create mode 100644 Samples_Obfuscated/BenchmarkTest00327.py create mode 100644 Samples_Obfuscated/BenchmarkTest00328.py create mode 100644 Samples_Obfuscated/BenchmarkTest00331.py create mode 100644 Samples_Obfuscated/BenchmarkTest00334.py create mode 100644 Samples_Obfuscated/BenchmarkTest00335.py create mode 100644 Samples_Obfuscated/BenchmarkTest00339.py create mode 100644 Samples_Obfuscated/BenchmarkTest00351.py create mode 100644 Samples_Obfuscated/BenchmarkTest00366.py create mode 100644 Samples_Obfuscated/BenchmarkTest00390.py create mode 100644 Samples_Obfuscated/BenchmarkTest00394.py create mode 100644 Samples_Obfuscated/BenchmarkTest00408.py create mode 100644 Samples_Obfuscated/BenchmarkTest00412.py create mode 100644 Samples_Obfuscated/BenchmarkTest00430.py create mode 100644 Samples_Obfuscated/BenchmarkTest00433.py create mode 100644 Samples_Obfuscated/BenchmarkTest00434.py create mode 100644 Samples_Obfuscated/BenchmarkTest00436.py create mode 100644 Samples_Obfuscated/BenchmarkTest00439.py create mode 100644 Samples_Obfuscated/BenchmarkTest00441.py create mode 100644 Samples_Obfuscated/BenchmarkTest00448.py create mode 100644 Samples_Obfuscated/BenchmarkTest00450.py create mode 100644 Samples_Obfuscated/BenchmarkTest00452.py create mode 100644 Samples_Obfuscated/BenchmarkTest00458.py create mode 100644 Samples_Obfuscated/BenchmarkTest00461.py create mode 100644 Samples_Obfuscated/BenchmarkTest00467.py create mode 100644 Samples_Obfuscated/BenchmarkTest00469.py create mode 100644 Samples_Obfuscated/BenchmarkTest00470.py create mode 100644 Samples_Obfuscated/BenchmarkTest00472.py create mode 100644 Samples_Obfuscated/BenchmarkTest00477.py create mode 100644 Samples_Obfuscated/BenchmarkTest00488.py create mode 100644 Samples_Obfuscated/BenchmarkTest00491.py create mode 100644 Samples_Obfuscated/BenchmarkTest00494.py create mode 100644 Samples_Obfuscated/BenchmarkTest00498.py create mode 100644 Samples_Obfuscated/BenchmarkTest00502.py create mode 100644 Samples_Obfuscated/BenchmarkTest00506.py create mode 100644 Samples_Obfuscated/BenchmarkTest00508.py create mode 100644 Samples_Obfuscated/BenchmarkTest00515.py create mode 100644 Samples_Obfuscated/BenchmarkTest00539.py create mode 100644 Samples_Obfuscated/BenchmarkTest00540.py create mode 100644 Samples_Obfuscated/BenchmarkTest00542.py create mode 100644 Samples_Obfuscated/BenchmarkTest00543.py create mode 100644 Samples_Obfuscated/BenchmarkTest00547.py create mode 100644 Samples_Obfuscated/BenchmarkTest00549.py create mode 100644 Samples_Obfuscated/BenchmarkTest00553.py create mode 100644 Samples_Obfuscated/BenchmarkTest00564.py create mode 100644 Samples_Obfuscated/BenchmarkTest00570.py create mode 100644 Samples_Obfuscated/BenchmarkTest00571.py create mode 100644 Samples_Obfuscated/BenchmarkTest00593.py create mode 100644 Samples_Obfuscated/BenchmarkTest00601.py create mode 100644 Samples_Obfuscated/BenchmarkTest00602.py create mode 100644 Samples_Obfuscated/BenchmarkTest00612.py create mode 100644 Samples_Obfuscated/BenchmarkTest00630.py create mode 100644 Samples_Obfuscated/BenchmarkTest00639.py create mode 100644 Samples_Obfuscated/BenchmarkTest00645.py create mode 100644 Samples_Obfuscated/BenchmarkTest00647.py create mode 100644 Samples_Obfuscated/BenchmarkTest00664.py create mode 100644 Samples_Obfuscated/BenchmarkTest00665.py create mode 100644 Samples_Obfuscated/BenchmarkTest00677.py create mode 100644 Samples_Obfuscated/BenchmarkTest00690.py create mode 100644 Samples_Obfuscated/BenchmarkTest00693.py create mode 100644 Samples_Obfuscated/BenchmarkTest00695.py create mode 100644 Samples_Obfuscated/BenchmarkTest00697.py create mode 100644 Samples_Obfuscated/BenchmarkTest00705.py create mode 100644 Samples_Obfuscated/BenchmarkTest00726.py create mode 100644 Samples_Obfuscated/BenchmarkTest00728.py create mode 100644 Samples_Obfuscated/BenchmarkTest00736.py create mode 100644 Samples_Obfuscated/BenchmarkTest00741.py create mode 100644 Samples_Obfuscated/BenchmarkTest00742.py create mode 100644 Samples_Obfuscated/BenchmarkTest00744.py create mode 100644 Samples_Obfuscated/BenchmarkTest00748.py create mode 100644 Samples_Obfuscated/BenchmarkTest00759.py create mode 100644 Samples_Obfuscated/BenchmarkTest00765.py create mode 100644 Samples_Obfuscated/BenchmarkTest00766.py create mode 100644 Samples_Obfuscated/BenchmarkTest00776.py create mode 100644 Samples_Obfuscated/BenchmarkTest00778.py create mode 100644 Samples_Obfuscated/BenchmarkTest00779.py create mode 100644 Samples_Obfuscated/BenchmarkTest00782.py create mode 100644 Samples_Obfuscated/BenchmarkTest00789.py create mode 100644 Samples_Obfuscated/BenchmarkTest00811.py create mode 100644 Samples_Obfuscated/BenchmarkTest00818.py create mode 100644 Samples_Obfuscated/BenchmarkTest00822.py create mode 100644 Samples_Obfuscated/BenchmarkTest00825.py create mode 100644 Samples_Obfuscated/BenchmarkTest00834.py create mode 100644 Samples_Obfuscated/BenchmarkTest00842.py create mode 100644 Samples_Obfuscated/BenchmarkTest00860.py create mode 100644 Samples_Obfuscated/BenchmarkTest00865.py create mode 100644 Samples_Obfuscated/BenchmarkTest00866.py create mode 100644 Samples_Obfuscated/BenchmarkTest00867.py create mode 100644 Samples_Obfuscated/BenchmarkTest00868.py create mode 100644 Samples_Obfuscated/BenchmarkTest00878.py create mode 100644 Samples_Obfuscated/BenchmarkTest00883.py create mode 100644 Samples_Obfuscated/BenchmarkTest00891.py create mode 100644 Samples_Obfuscated/BenchmarkTest00898.py create mode 100644 Samples_Obfuscated/BenchmarkTest00920.py create mode 100644 Samples_Obfuscated/BenchmarkTest00925.py create mode 100644 Samples_Obfuscated/BenchmarkTest00929.py create mode 100644 Samples_Obfuscated/BenchmarkTest00930.py create mode 100644 Samples_Obfuscated/BenchmarkTest00940.py create mode 100644 Samples_Obfuscated/BenchmarkTest00941.py create mode 100644 Samples_Obfuscated/BenchmarkTest00947.py create mode 100644 Samples_Obfuscated/BenchmarkTest00957.py create mode 100644 Samples_Obfuscated/BenchmarkTest00959.py create mode 100644 Samples_Obfuscated/BenchmarkTest00969.py create mode 100644 Samples_Obfuscated/BenchmarkTest00974.py create mode 100644 Samples_Obfuscated/BenchmarkTest00995.py create mode 100644 Samples_Obfuscated/BenchmarkTest00996.py create mode 100644 Samples_Obfuscated/BenchmarkTest01001.py create mode 100644 Samples_Obfuscated/BenchmarkTest01011.py create mode 100644 Samples_Obfuscated/BenchmarkTest01023.py create mode 100644 Samples_Obfuscated/BenchmarkTest01026.py create mode 100644 Samples_Obfuscated/BenchmarkTest01035.py create mode 100644 Samples_Obfuscated/BenchmarkTest01040.py create mode 100644 Samples_Obfuscated/BenchmarkTest01044.py create mode 100644 Samples_Obfuscated/BenchmarkTest01053.py create mode 100644 Samples_Obfuscated/BenchmarkTest01060.py create mode 100644 Samples_Obfuscated/BenchmarkTest01081.py create mode 100644 Samples_Obfuscated/BenchmarkTest01084.py create mode 100644 Samples_Obfuscated/BenchmarkTest01087.py create mode 100644 Samples_Obfuscated/BenchmarkTest01091.py create mode 100644 Samples_Obfuscated/BenchmarkTest01094.py create mode 100644 Samples_Obfuscated/BenchmarkTest01099.py create mode 100644 Samples_Obfuscated/BenchmarkTest01100.py create mode 100644 Samples_Obfuscated/BenchmarkTest01104.py create mode 100644 Samples_Obfuscated/BenchmarkTest01105.py create mode 100644 Samples_Obfuscated/BenchmarkTest01117.py create mode 100644 Samples_Obfuscated/BenchmarkTest01126.py create mode 100644 Samples_Obfuscated/BenchmarkTest01131.py create mode 100644 Samples_Obfuscated/BenchmarkTest01134.py create mode 100644 Samples_Obfuscated/BenchmarkTest01135.py create mode 100644 Samples_Obfuscated/BenchmarkTest01141.py create mode 100644 Samples_Obfuscated/BenchmarkTest01150.py create mode 100644 Samples_Obfuscated/BenchmarkTest01162.py create mode 100644 Samples_Obfuscated/BenchmarkTest01170.py create mode 100644 Samples_Obfuscated/BenchmarkTest01181.py create mode 100644 Samples_Obfuscated/BenchmarkTest01183.py create mode 100644 Samples_Obfuscated/BenchmarkTest01196.py create mode 100644 Samples_Obfuscated/BenchmarkTest01198.py create mode 100644 Samples_Obfuscated/BenchmarkTest01205.py create mode 100644 Samples_Obfuscated/BenchmarkTest01206.py create mode 100644 Samples_Obfuscated/BenchmarkTest01207.py create mode 100644 Samples_Obfuscated/BenchmarkTest01210.py create mode 100644 Samples_Obfuscated/BenchmarkTest01221.py create mode 100644 Samples_Obfuscated/BenchmarkTest01222.py create mode 100644 Samples_Obfuscated/BenchmarkTest01227.py create mode 100644 obfuscator.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..65776d1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +__pycache__/ +*.py[cod] +.venv/ +venv/ diff --git a/Samples/BenchmarkTest00002.py b/Samples/BenchmarkTest00002.py new file mode 100644 index 0000000..2149839 --- /dev/null +++ b/Samples/BenchmarkTest00002.py @@ -0,0 +1,65 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/pathtraver-00/BenchmarkTest00002', methods=['GET']) + def BenchmarkTest00002_get(): + response = make_response(render_template('web/pathtraver-00/BenchmarkTest00002.html')) + response.set_cookie('BenchmarkTest00002', 'Filename', + max_age=60*3, + secure=True, + path=request.path, + domain='localhost') + return response + return BenchmarkTest00002_post() + + @app.route('/benchmark/pathtraver-00/BenchmarkTest00002', methods=['POST']) + def BenchmarkTest00002_post(): + RESPONSE = "" + + import urllib.parse + param = urllib.parse.unquote_plus(request.cookies.get("BenchmarkTest00002", "noCookieValueSupplied")) + + bar = "This should never happen" + if 'should' in bar: + bar = param + + import codecs + import helpers.utils + + try: + fileTarget = codecs.open(f'{helpers.utils.TESTFILES_DIR}/{bar}','r','utf-8') + + RESPONSE += ( + f"Access to file: \'{escape_for_html(fileTarget.name)}\' created." + ) + + RESPONSE += ( + " And file already exists." + ) + + except FileNotFoundError: + RESPONSE += ( + " But file doesn't exist yet." + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00007.py b/Samples/BenchmarkTest00007.py new file mode 100644 index 0000000..fdbbc5e --- /dev/null +++ b/Samples/BenchmarkTest00007.py @@ -0,0 +1,73 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/pathtraver-00/BenchmarkTest00007', methods=['GET']) + def BenchmarkTest00007_get(): + response = make_response(render_template('web/pathtraver-00/BenchmarkTest00007.html')) + response.set_cookie('BenchmarkTest00007', 'FileName', + max_age=60*3, + secure=True, + path=request.path, + domain='localhost') + return response + return BenchmarkTest00007_post() + + @app.route('/benchmark/pathtraver-00/BenchmarkTest00007', methods=['POST']) + def BenchmarkTest00007_post(): + RESPONSE = "" + + import urllib.parse + param = urllib.parse.unquote_plus(request.cookies.get("BenchmarkTest00007", "noCookieValueSupplied")) + + string22532 = 'help' + string22532 += param + string22532 += 'snapes on a plane' + bar = string22532[4:-17] + + import helpers.utils + + if '../' in bar: + RESPONSE += ( + 'File name must not contain \'../\'' + ) + return RESPONSE + + try: + fileName = f'{helpers.utils.TESTFILES_DIR}/{bar}' + fd = open(fileName, 'wb') + RESPONSE += ( + f'Now ready to write to file: {escape_for_html(fileName)}' + ) + except IOError as e: + RESPONSE += ( + f'Problem reading from file \'{escape_for_html(fileName)}\': ' + f'{escape_for_html(e.strerror)}' + ) + finally: + try: + if fd is not None: + fd.close() + except IOError: + pass # "// we tried..." + + return RESPONSE + diff --git a/Samples/BenchmarkTest00014.py b/Samples/BenchmarkTest00014.py new file mode 100644 index 0000000..32b4039 --- /dev/null +++ b/Samples/BenchmarkTest00014.py @@ -0,0 +1,72 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xpathi-00/BenchmarkTest00014', methods=['GET']) + def BenchmarkTest00014_get(): + response = make_response(render_template('web/xpathi-00/BenchmarkTest00014.html')) + response.set_cookie('BenchmarkTest00014', '2222', + max_age=60*3, + secure=True, + path=request.path, + domain='localhost') + return response + return BenchmarkTest00014_post() + + @app.route('/benchmark/xpathi-00/BenchmarkTest00014', methods=['POST']) + def BenchmarkTest00014_post(): + RESPONSE = "" + + import urllib.parse + param = urllib.parse.unquote_plus(request.cookies.get("BenchmarkTest00014", "noCookieValueSupplied")) + + import base64 + tmp = base64.b64encode(param.encode('utf-8')) + bar = base64.b64decode(tmp).decode('utf-8') + + import elementpath + import xml.etree.ElementTree as ET + import helpers.utils + + if '\'' in bar: + RESPONSE += ( + "Employee ID must not contain apostrophes" + ) + return RESPONSE + + try: + root = ET.parse(f'{helpers.utils.RES_DIR}/employees.xml') + query = f"/Employees/Employee[@emplid=\'{bar}\']" + nodes = elementpath.select(root, query) + node_strings = [] + for node in nodes: + node_strings.append(' '.join([e.text for e in node])) + + RESPONSE += ( + f'Your XPATH query results are:
[ {', '.join(node_strings)} ]' + ) + except: + RESPONSE += ( + f'Error parsing XPath Query: \'{escape_for_html(query)}\'' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00015.py b/Samples/BenchmarkTest00015.py new file mode 100644 index 0000000..40bbd45 --- /dev/null +++ b/Samples/BenchmarkTest00015.py @@ -0,0 +1,72 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xpathi-00/BenchmarkTest00015', methods=['GET']) + def BenchmarkTest00015_get(): + response = make_response(render_template('web/xpathi-00/BenchmarkTest00015.html')) + response.set_cookie('BenchmarkTest00015', '2222', + max_age=60*3, + secure=True, + path=request.path, + domain='localhost') + return response + return BenchmarkTest00015_post() + + @app.route('/benchmark/xpathi-00/BenchmarkTest00015', methods=['POST']) + def BenchmarkTest00015_post(): + RESPONSE = "" + + import urllib.parse + param = urllib.parse.unquote_plus(request.cookies.get("BenchmarkTest00015", "noCookieValueSupplied")) + + bar = "This should never happen" + if 'should' in bar: + bar = param + + import elementpath + import xml.etree.ElementTree as ET + import helpers.utils + + if '\'' in bar: + RESPONSE += ( + "Employee ID must not contain apostrophes" + ) + return RESPONSE + + try: + root = ET.parse(f'{helpers.utils.RES_DIR}/employees.xml') + query = f"/Employees/Employee[@emplid=\'{bar}\']" + nodes = elementpath.select(root, query) + node_strings = [] + for node in nodes: + node_strings.append(' '.join([e.text for e in node])) + + RESPONSE += ( + f'Your XPATH query results are:
[ {', '.join(node_strings)} ]' + ) + except: + RESPONSE += ( + f'Error parsing XPath Query: \'{escape_for_html(query)}\'' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00024.py b/Samples/BenchmarkTest00024.py new file mode 100644 index 0000000..dbca7ec --- /dev/null +++ b/Samples/BenchmarkTest00024.py @@ -0,0 +1,77 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xpathi-00/BenchmarkTest00024', methods=['GET']) + def BenchmarkTest00024_get(): + response = make_response(render_template('web/xpathi-00/BenchmarkTest00024.html')) + response.set_cookie('BenchmarkTest00024', '2222', + max_age=60*3, + secure=True, + path=request.path, + domain='localhost') + return response + return BenchmarkTest00024_post() + + @app.route('/benchmark/xpathi-00/BenchmarkTest00024', methods=['POST']) + def BenchmarkTest00024_post(): + RESPONSE = "" + + import urllib.parse + param = urllib.parse.unquote_plus(request.cookies.get("BenchmarkTest00024", "noCookieValueSupplied")) + + import configparser + + bar = 'safe!' + conf57764 = configparser.ConfigParser() + conf57764.add_section('section57764') + conf57764.set('section57764', 'keyA-57764', 'a_Value') + conf57764.set('section57764', 'keyB-57764', param) + bar = conf57764.get('section57764', 'keyA-57764') + + import lxml.etree + import helpers.utils + import io + + try: + fd = open(f'{helpers.utils.RES_DIR}/employees.xml', 'rb') + root = lxml.etree.parse(fd) + strIO = io.StringIO() + strIO.write('/Employees/Employee[@emplid=\'') + strIO.write(bar) + strIO.write('\']') + query = strIO.getvalue() + + nodes = root.xpath(query) + node_strings = [] + for node in nodes: + node_strings.append(' '.join([e.text for e in node])) + + RESPONSE += ( + f'Your XPATH query results are:
[ {', '.join(node_strings)} ]' + ) + except: + RESPONSE += ( + f'Error parsing XPath Query: \'{escape_for_html(query)}\'' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00040.py b/Samples/BenchmarkTest00040.py new file mode 100644 index 0000000..8356956 --- /dev/null +++ b/Samples/BenchmarkTest00040.py @@ -0,0 +1,67 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-00/BenchmarkTest00040', methods=['GET']) + def BenchmarkTest00040_get(): + response = make_response(render_template('web/weakrand-00/BenchmarkTest00040.html')) + response.set_cookie('BenchmarkTest00040', 'whatever', + max_age=60*3, + secure=True, + path=request.path, + domain='localhost') + return response + return BenchmarkTest00040_post() + + @app.route('/benchmark/weakrand-00/BenchmarkTest00040', methods=['POST']) + def BenchmarkTest00040_post(): + RESPONSE = "" + + import urllib.parse + param = urllib.parse.unquote_plus(request.cookies.get("BenchmarkTest00040", "noCookieValueSupplied")) + + string47148 = 'help' + string47148 += param + string47148 += 'snapes on a plane' + bar = string47148[4:-17] + + import base64 + import secrets + from helpers.utils import mysession + + num = 'BenchmarkTest00040'[13:] + user = f'SafeToby{num}' + cookie = f'rememberMe{num}' + value = base64.b64encode(secrets.token_bytes(32)) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie:' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00044.py b/Samples/BenchmarkTest00044.py new file mode 100644 index 0000000..13d5e32 --- /dev/null +++ b/Samples/BenchmarkTest00044.py @@ -0,0 +1,65 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-00/BenchmarkTest00044', methods=['GET']) + def BenchmarkTest00044_get(): + response = make_response(render_template('web/weakrand-00/BenchmarkTest00044.html')) + response.set_cookie('BenchmarkTest00044', 'whatever', + max_age=60*3, + secure=True, + path=request.path, + domain='localhost') + return response + return BenchmarkTest00044_post() + + @app.route('/benchmark/weakrand-00/BenchmarkTest00044', methods=['POST']) + def BenchmarkTest00044_post(): + RESPONSE = "" + + import urllib.parse + param = urllib.parse.unquote_plus(request.cookies.get("BenchmarkTest00044", "noCookieValueSupplied")) + + import base64 + tmp = base64.b64encode(param.encode('utf-8')) + bar = base64.b64decode(tmp).decode('utf-8') + + import random + from helpers.utils import mysession + + num = 'BenchmarkTest00044'[13:] + user = f'SafeRandy{num}' + cookie = f'rememberMe{num}' + value = str(random.SystemRandom().getrandbits(32)) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie: ' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00052.py b/Samples/BenchmarkTest00052.py new file mode 100644 index 0000000..2fcddec --- /dev/null +++ b/Samples/BenchmarkTest00052.py @@ -0,0 +1,70 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-00/BenchmarkTest00052', methods=['GET']) + def BenchmarkTest00052_get(): + response = make_response(render_template('web/weakrand-00/BenchmarkTest00052.html')) + response.set_cookie('BenchmarkTest00052', 'whatever', + max_age=60*3, + secure=True, + path=request.path, + domain='localhost') + return response + return BenchmarkTest00052_post() + + @app.route('/benchmark/weakrand-00/BenchmarkTest00052', methods=['POST']) + def BenchmarkTest00052_post(): + RESPONSE = "" + + import urllib.parse + param = urllib.parse.unquote_plus(request.cookies.get("BenchmarkTest00052", "noCookieValueSupplied")) + + bar = "" + if param: + lst = [] + lst.append('safe') + lst.append(param) + lst.append('moresafe') + lst.pop(0) + bar = lst[0] + + import random + from helpers.utils import mysession + + num = 'BenchmarkTest00052'[13:] + user = f'SafeRandall{num}' + cookie = f'rememberMe{num}' + value = str(random.SystemRandom().random())[2:] + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie: ' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00055.py b/Samples/BenchmarkTest00055.py new file mode 100644 index 0000000..dd59392 --- /dev/null +++ b/Samples/BenchmarkTest00055.py @@ -0,0 +1,72 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/hash-00/BenchmarkTest00055', methods=['GET']) + def BenchmarkTest00055_get(): + response = make_response(render_template('web/hash-00/BenchmarkTest00055.html')) + response.set_cookie('BenchmarkTest00055', 'someSecret', + max_age=60*3, + secure=True, + path=request.path, + domain='localhost') + return response + return BenchmarkTest00055_post() + + @app.route('/benchmark/hash-00/BenchmarkTest00055', methods=['POST']) + def BenchmarkTest00055_post(): + RESPONSE = "" + + import urllib.parse + param = urllib.parse.unquote_plus(request.cookies.get("BenchmarkTest00055", "noCookieValueSupplied")) + + num = 106 + + bar = "This should never happen" if (7*42) - num > 200 else param + + import hashlib, base64 + import io, helpers.utils + + input = '' + if isinstance(bar, str): + input = bar.encode('utf-8') + elif isinstance(bar, io.IOBase): + input = bar.read(1000) + + if len(input) == 0: + RESPONSE += ( + 'Cannot generate hash: Input was empty.' + ) + return RESPONSE + + hash = hashlib.new('sha384') + hash.update(input) + + result = hash.digest() + f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + f.write(f'hash_value={base64.b64encode(result)}\n') + RESPONSE += ( + f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.' + ) + f.close() + + return RESPONSE + diff --git a/Samples/BenchmarkTest00062.py b/Samples/BenchmarkTest00062.py new file mode 100644 index 0000000..e3cd1cb --- /dev/null +++ b/Samples/BenchmarkTest00062.py @@ -0,0 +1,74 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/hash-00/BenchmarkTest00062', methods=['GET']) + def BenchmarkTest00062_get(): + response = make_response(render_template('web/hash-00/BenchmarkTest00062.html')) + response.set_cookie('BenchmarkTest00062', 'someSecret', + max_age=60*3, + secure=True, + path=request.path, + domain='localhost') + return response + return BenchmarkTest00062_post() + + @app.route('/benchmark/hash-00/BenchmarkTest00062', methods=['POST']) + def BenchmarkTest00062_post(): + RESPONSE = "" + + import urllib.parse + param = urllib.parse.unquote_plus(request.cookies.get("BenchmarkTest00062", "noCookieValueSupplied")) + + TestParam = "This should never happen" + if 'should' not in TestParam: + bar = "Ifnot case passed" + else: + bar = param + + import hashlib, base64 + import io, helpers.utils + + input = '' + if isinstance(bar, str): + input = bar.encode('utf-8') + elif isinstance(bar, io.IOBase): + input = bar.read(1000) + + if len(input) == 0: + RESPONSE += ( + 'Cannot generate hash: Input was empty.' + ) + return RESPONSE + + hash = hashlib.sha512() + hash.update(input) + + result = hash.digest() + f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + f.write(f'hash_value={base64.b64encode(result)}\n') + RESPONSE += ( + f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.' + ) + f.close() + + return RESPONSE + diff --git a/Samples/BenchmarkTest00065.py b/Samples/BenchmarkTest00065.py new file mode 100644 index 0000000..a2dbc43 --- /dev/null +++ b/Samples/BenchmarkTest00065.py @@ -0,0 +1,69 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/securecookie-00/BenchmarkTest00065', methods=['GET']) + def BenchmarkTest00065_get(): + response = make_response(render_template('web/securecookie-00/BenchmarkTest00065.html')) + response.set_cookie('BenchmarkTest00065', 'whatever', + max_age=60*3, + secure=True, + path=request.path, + domain='localhost') + return response + return BenchmarkTest00065_post() + + @app.route('/benchmark/securecookie-00/BenchmarkTest00065', methods=['POST']) + def BenchmarkTest00065_post(): + RESPONSE = "" + + import urllib.parse + param = urllib.parse.unquote_plus(request.cookies.get("BenchmarkTest00065", "noCookieValueSupplied")) + + import html + + bar = html.escape(param) + + from flask import make_response + import io + import helpers.utils + + input = '' + if isinstance(bar, str): + input = bar.encode('utf-8') + elif isinstance(bar, io.IOBase): + input = bar.read(1000) + + cookie = 'SomeCookie' + value = input.decode('utf-8') + + RESPONSE += ( + f'Created cookie: \'{cookie}\' with value \'{helpers.utils.escape_for_html(value)}\' and secure flag set to false.' + ) + + RESPONSE = make_response(RESPONSE) + RESPONSE.set_cookie(cookie, value, + path=request.path, + secure=False, + httponly=True) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00066.py b/Samples/BenchmarkTest00066.py new file mode 100644 index 0000000..9f5bc68 --- /dev/null +++ b/Samples/BenchmarkTest00066.py @@ -0,0 +1,69 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/securecookie-00/BenchmarkTest00066', methods=['GET']) + def BenchmarkTest00066_get(): + response = make_response(render_template('web/securecookie-00/BenchmarkTest00066.html')) + response.set_cookie('BenchmarkTest00066', 'whatever', + max_age=60*3, + secure=True, + path=request.path, + domain='localhost') + return response + return BenchmarkTest00066_post() + + @app.route('/benchmark/securecookie-00/BenchmarkTest00066', methods=['POST']) + def BenchmarkTest00066_post(): + RESPONSE = "" + + import urllib.parse + param = urllib.parse.unquote_plus(request.cookies.get("BenchmarkTest00066", "noCookieValueSupplied")) + + bar = "This should never happen" + if 'should' in bar: + bar = param + + from flask import make_response + import io + import helpers.utils + + input = '' + if isinstance(bar, str): + input = bar.encode('utf-8') + elif isinstance(bar, io.IOBase): + input = bar.read(1000) + + cookie = 'SomeCookie' + value = input.decode('utf-8') + + RESPONSE += ( + f'Created cookie: \'{cookie}\' with value \'{helpers.utils.escape_for_html(value)}\' and secure flag set to false.' + ) + + RESPONSE = make_response(RESPONSE) + RESPONSE.set_cookie(cookie, value, + path=request.path, + secure=False, + httponly=True) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00089.py b/Samples/BenchmarkTest00089.py new file mode 100644 index 0000000..8f18137 --- /dev/null +++ b/Samples/BenchmarkTest00089.py @@ -0,0 +1,52 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/pathtraver-00/BenchmarkTest00089', methods=['GET']) + def BenchmarkTest00089_get(): + return BenchmarkTest00089_post() + + @app.route('/benchmark/pathtraver-00/BenchmarkTest00089', methods=['POST']) + def BenchmarkTest00089_post(): + RESPONSE = "" + + param = request.form.get("BenchmarkTest00089") + if not param: + param = "" + + map83150 = {} + map83150['keyA-83150'] = 'a-Value' + map83150['keyB-83150'] = param + map83150['keyC'] = 'another-Value' + bar = map83150['keyB-83150'] + + import pathlib + import helpers.utils + + testfiles = pathlib.Path(helpers.utils.TESTFILES_DIR) + p = testfiles / bar + if p.exists(): + RESPONSE += ( f"File \'{escape_for_html(str(p))}\' exists." ) + else: + RESPONSE += ( f"File \'{escape_for_html(str(p))}\' does not exist." ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00094.py b/Samples/BenchmarkTest00094.py new file mode 100644 index 0000000..ff4652a --- /dev/null +++ b/Samples/BenchmarkTest00094.py @@ -0,0 +1,63 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/pathtraver-00/BenchmarkTest00094', methods=['GET']) + def BenchmarkTest00094_get(): + return BenchmarkTest00094_post() + + @app.route('/benchmark/pathtraver-00/BenchmarkTest00094', methods=['POST']) + def BenchmarkTest00094_post(): + RESPONSE = "" + + param = request.form.get("BenchmarkTest00094") + if not param: + param = "" + + num = 106 + + bar = "This_should_always_happen" if 7 * 18 + num > 200 else param + + import pathlib + import helpers.utils + + try: + testfiles = pathlib.Path(helpers.utils.TESTFILES_DIR) + p = (testfiles / bar).resolve() + + if not str(p).startswith(str(testfiles)): + RESPONSE += ( + "Invalid Path." + ) + return RESPONSE + + RESPONSE += ( + f'The beginning of file: \'{escape_for_html(str(p))}\' is:\n\n' + f'{escape_for_html(p.read_text()[:1000])}' + ) + except OSError: + RESPONSE += ( + f'Problem reading from file \'{{escape_for_html(fileName)}}\': ' + f'{escape_for_html(e.strerror)}' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00097.py b/Samples/BenchmarkTest00097.py new file mode 100644 index 0000000..bb18b71 --- /dev/null +++ b/Samples/BenchmarkTest00097.py @@ -0,0 +1,46 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xss-00/BenchmarkTest00097', methods=['GET']) + def BenchmarkTest00097_get(): + return BenchmarkTest00097_post() + + @app.route('/benchmark/xss-00/BenchmarkTest00097', methods=['POST']) + def BenchmarkTest00097_post(): + RESPONSE = "" + + param = request.form.get("BenchmarkTest00097") + if not param: + param = "" + + bar = '' + if param: + bar = param.split(' ')[0] + + + otherarg = "static text" + RESPONSE += ( + f'bar is \'{bar}\' and otherarg is \'{otherarg}\'' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00111.py b/Samples/BenchmarkTest00111.py new file mode 100644 index 0000000..1ada447 --- /dev/null +++ b/Samples/BenchmarkTest00111.py @@ -0,0 +1,60 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xpathi-00/BenchmarkTest00111', methods=['GET']) + def BenchmarkTest00111_get(): + return BenchmarkTest00111_post() + + @app.route('/benchmark/xpathi-00/BenchmarkTest00111', methods=['POST']) + def BenchmarkTest00111_post(): + RESPONSE = "" + + param = request.form.get("BenchmarkTest00111") + if not param: + param = "" + + bar = "This should never happen" + if 'should' in bar: + bar = param + + import lxml.etree + import helpers.utils + + try: + fd = open(f'{helpers.utils.RES_DIR}/employees.xml', 'rb') + root = lxml.etree.parse(fd) + query = f'/Employees/Employee[@emplid=$name]' + nodes = root.xpath(query, name=bar) + node_strings = [] + for node in nodes: + node_strings.append(' '.join([e.text for e in node])) + + RESPONSE += ( + f'Your XPATH query results are:
[ {', '.join(node_strings)} ]' + ) + except: + RESPONSE += ( + f'Error parsing XPath Query: \'{escape_for_html(query)}\'' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00115.py b/Samples/BenchmarkTest00115.py new file mode 100644 index 0000000..abf1d6f --- /dev/null +++ b/Samples/BenchmarkTest00115.py @@ -0,0 +1,59 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-00/BenchmarkTest00115', methods=['GET']) + def BenchmarkTest00115_get(): + return BenchmarkTest00115_post() + + @app.route('/benchmark/weakrand-00/BenchmarkTest00115', methods=['POST']) + def BenchmarkTest00115_post(): + RESPONSE = "" + + param = request.form.get("BenchmarkTest00115") + if not param: + param = "" + + bar = '' + if param: + bar = param.split(' ')[0] + + import random + from helpers.utils import mysession + + num = 'BenchmarkTest00115'[13:] + user = f'Randy{num}' + cookie = f'rememberMe{num}' + value = str(random.getrandbits(32)) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie: ' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00119.py b/Samples/BenchmarkTest00119.py new file mode 100644 index 0000000..392debe --- /dev/null +++ b/Samples/BenchmarkTest00119.py @@ -0,0 +1,68 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-00/BenchmarkTest00119', methods=['GET']) + def BenchmarkTest00119_get(): + return BenchmarkTest00119_post() + + @app.route('/benchmark/weakrand-00/BenchmarkTest00119', methods=['POST']) + def BenchmarkTest00119_post(): + RESPONSE = "" + + param = request.form.get("BenchmarkTest00119") + if not param: + param = "" + + possible = "ABC" + guess = possible[1] + + match guess: + case 'A': + bar = param + case 'B': + bar = 'bob' + case 'C' | 'D': + bar = param + case _: + bar = 'bob\'s your uncle' + + import secrets + from helpers.utils import mysession + + num = 'BenchmarkTest00119'[13:] + user = f'SafeRobbie{num}' + cookie = f'rememberMe{num}' + value = str(secrets.randbelow(2**32)) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie:' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00121.py b/Samples/BenchmarkTest00121.py new file mode 100644 index 0000000..924e122 --- /dev/null +++ b/Samples/BenchmarkTest00121.py @@ -0,0 +1,65 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-00/BenchmarkTest00121', methods=['GET']) + def BenchmarkTest00121_get(): + return BenchmarkTest00121_post() + + @app.route('/benchmark/weakrand-00/BenchmarkTest00121', methods=['POST']) + def BenchmarkTest00121_post(): + RESPONSE = "" + + param = request.form.get("BenchmarkTest00121") + if not param: + param = "" + + import configparser + + bar = 'safe!' + conf68097 = configparser.ConfigParser() + conf68097.add_section('section68097') + conf68097.set('section68097', 'keyA-68097', 'a-Value') + conf68097.set('section68097', 'keyB-68097', param) + bar = conf68097.get('section68097', 'keyB-68097') + + import base64 + import secrets + from helpers.utils import mysession + + num = 'BenchmarkTest00121'[13:] + user = f'SafeToby{num}' + cookie = f'rememberMe{num}' + value = base64.b64encode(secrets.token_bytes(32)) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie:' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00125.py b/Samples/BenchmarkTest00125.py new file mode 100644 index 0000000..3c4ea08 --- /dev/null +++ b/Samples/BenchmarkTest00125.py @@ -0,0 +1,59 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-00/BenchmarkTest00125', methods=['GET']) + def BenchmarkTest00125_get(): + return BenchmarkTest00125_post() + + @app.route('/benchmark/weakrand-00/BenchmarkTest00125', methods=['POST']) + def BenchmarkTest00125_post(): + RESPONSE = "" + + param = request.form.get("BenchmarkTest00125") + if not param: + param = "" + + superstring = f'94919{param}abcd' + bar = superstring[len('94919'):len(superstring)-5] + + import base64 + import secrets + from helpers.utils import mysession + + num = 'BenchmarkTest00125'[13:] + user = f'SafeToby{num}' + cookie = f'rememberMe{num}' + value = base64.b64encode(secrets.token_bytes(32)) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie:' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00131.py b/Samples/BenchmarkTest00131.py new file mode 100644 index 0000000..95848ae --- /dev/null +++ b/Samples/BenchmarkTest00131.py @@ -0,0 +1,57 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-00/BenchmarkTest00131', methods=['GET']) + def BenchmarkTest00131_get(): + return BenchmarkTest00131_post() + + @app.route('/benchmark/weakrand-00/BenchmarkTest00131', methods=['POST']) + def BenchmarkTest00131_post(): + RESPONSE = "" + + param = request.form.get("BenchmarkTest00131") + if not param: + param = "" + + bar = param + '_SafeStuff' + + import random + from helpers.utils import mysession + + num = 'BenchmarkTest00131'[13:] + user = f'SafeRandy{num}' + cookie = f'rememberMe{num}' + value = str(random.SystemRandom().getrandbits(32)) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie: ' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00132.py b/Samples/BenchmarkTest00132.py new file mode 100644 index 0000000..7fbb42a --- /dev/null +++ b/Samples/BenchmarkTest00132.py @@ -0,0 +1,58 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-00/BenchmarkTest00132', methods=['GET']) + def BenchmarkTest00132_get(): + return BenchmarkTest00132_post() + + @app.route('/benchmark/weakrand-00/BenchmarkTest00132', methods=['POST']) + def BenchmarkTest00132_post(): + RESPONSE = "" + + param = request.form.get("BenchmarkTest00132") + if not param: + param = "" + + import helpers.utils + bar = helpers.utils.escape_for_html(param) + + import random + from helpers.utils import mysession + + num = 'BenchmarkTest00132'[13:] + user = f'SafeNancy{num}' + cookie = f'rememberMe{num}' + value = str(random.SystemRandom().normalvariate())[2:] + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie: ' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00136.py b/Samples/BenchmarkTest00136.py new file mode 100644 index 0000000..e1e52ef --- /dev/null +++ b/Samples/BenchmarkTest00136.py @@ -0,0 +1,64 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-00/BenchmarkTest00136', methods=['GET']) + def BenchmarkTest00136_get(): + return BenchmarkTest00136_post() + + @app.route('/benchmark/weakrand-00/BenchmarkTest00136', methods=['POST']) + def BenchmarkTest00136_post(): + RESPONSE = "" + + param = request.form.get("BenchmarkTest00136") + if not param: + param = "" + + string14469 = '' + data12 = '' + copy = string14469 + string14469 = '' + string14469 += param + copy += 'SomeOKString' + bar = copy + + import random + import base64 + from helpers.utils import mysession + + num = 'BenchmarkTest00136'[13:] + user = f'SafeBarbara{num}' + cookie = f'rememberMe{num}' + value = str(base64.b64encode(random.SystemRandom().randbytes(32))) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie: ' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00139.py b/Samples/BenchmarkTest00139.py new file mode 100644 index 0000000..221f222 --- /dev/null +++ b/Samples/BenchmarkTest00139.py @@ -0,0 +1,64 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-00/BenchmarkTest00139', methods=['GET']) + def BenchmarkTest00139_get(): + return BenchmarkTest00139_post() + + @app.route('/benchmark/weakrand-00/BenchmarkTest00139', methods=['POST']) + def BenchmarkTest00139_post(): + RESPONSE = "" + + param = request.form.get("BenchmarkTest00139") + if not param: + param = "" + + bar = "" + if param: + lst = [] + lst.append('safe') + lst.append(param) + lst.append('moresafe') + lst.pop(0) + bar = lst[0] + + import random + from helpers.utils import mysession + + num = 'BenchmarkTest00139'[13:] + user = f'SafeRandall{num}' + cookie = f'rememberMe{num}' + value = str(random.SystemRandom().random())[2:] + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie: ' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00142.py b/Samples/BenchmarkTest00142.py new file mode 100644 index 0000000..32bf611 --- /dev/null +++ b/Samples/BenchmarkTest00142.py @@ -0,0 +1,70 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/hash-00/BenchmarkTest00142', methods=['GET']) + def BenchmarkTest00142_get(): + return BenchmarkTest00142_post() + + @app.route('/benchmark/hash-00/BenchmarkTest00142', methods=['POST']) + def BenchmarkTest00142_post(): + RESPONSE = "" + + param = request.form.get("BenchmarkTest00142") + if not param: + param = "" + + map71621 = {} + map71621['keyA-71621'] = 'a-Value' + map71621['keyB-71621'] = param + map71621['keyC'] = 'another-Value' + bar = "safe!" + bar = map71621['keyB-71621'] + bar = map71621['keyA-71621'] + + import hashlib, base64 + import io, helpers.utils + + input = '' + if isinstance(bar, str): + input = bar.encode('utf-8') + elif isinstance(bar, io.IOBase): + input = bar.read(1000) + + if len(input) == 0: + RESPONSE += ( + 'Cannot generate hash: Input was empty.' + ) + return RESPONSE + + hash = hashlib.sha1() + hash.update(input) + + result = hash.digest() + f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + f.write(f'hash_value={base64.b64encode(result)}\n') + RESPONSE += ( + f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.' + ) + f.close() + + return RESPONSE + diff --git a/Samples/BenchmarkTest00143.py b/Samples/BenchmarkTest00143.py new file mode 100644 index 0000000..22541fe --- /dev/null +++ b/Samples/BenchmarkTest00143.py @@ -0,0 +1,66 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/hash-00/BenchmarkTest00143', methods=['GET']) + def BenchmarkTest00143_get(): + return BenchmarkTest00143_post() + + @app.route('/benchmark/hash-00/BenchmarkTest00143', methods=['POST']) + def BenchmarkTest00143_post(): + RESPONSE = "" + + param = request.form.get("BenchmarkTest00143") + if not param: + param = "" + + import html + + bar = html.escape(param) + + import hashlib, base64 + import io, helpers.utils + + input = '' + if isinstance(bar, str): + input = bar.encode('utf-8') + elif isinstance(bar, io.IOBase): + input = bar.read(1000) + + if len(input) == 0: + RESPONSE += ( + 'Cannot generate hash: Input was empty.' + ) + return RESPONSE + + hash = hashlib.sha1() + hash.update(input) + + result = hash.digest() + f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + f.write(f'hash_value={base64.b64encode(result)}\n') + RESPONSE += ( + f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.' + ) + f.close() + + return RESPONSE + diff --git a/Samples/BenchmarkTest00146.py b/Samples/BenchmarkTest00146.py new file mode 100644 index 0000000..6bb13cc --- /dev/null +++ b/Samples/BenchmarkTest00146.py @@ -0,0 +1,64 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/hash-00/BenchmarkTest00146', methods=['GET']) + def BenchmarkTest00146_get(): + return BenchmarkTest00146_post() + + @app.route('/benchmark/hash-00/BenchmarkTest00146', methods=['POST']) + def BenchmarkTest00146_post(): + RESPONSE = "" + + param = request.form.get("BenchmarkTest00146") + if not param: + param = "" + + bar = param + '_SafeStuff' + + import hashlib, base64 + import io, helpers.utils + + input = '' + if isinstance(bar, str): + input = bar.encode('utf-8') + elif isinstance(bar, io.IOBase): + input = bar.read(1000) + + if len(input) == 0: + RESPONSE += ( + 'Cannot generate hash: Input was empty.' + ) + return RESPONSE + + hash = hashlib.sha384() + hash.update(input) + + result = hash.digest() + f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + f.write(f'hash_value={base64.b64encode(result)}\n') + RESPONSE += ( + f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.' + ) + f.close() + + return RESPONSE + diff --git a/Samples/BenchmarkTest00147.py b/Samples/BenchmarkTest00147.py new file mode 100644 index 0000000..d1e1717 --- /dev/null +++ b/Samples/BenchmarkTest00147.py @@ -0,0 +1,64 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/hash-00/BenchmarkTest00147', methods=['GET']) + def BenchmarkTest00147_get(): + return BenchmarkTest00147_post() + + @app.route('/benchmark/hash-00/BenchmarkTest00147', methods=['POST']) + def BenchmarkTest00147_post(): + RESPONSE = "" + + param = request.form.get("BenchmarkTest00147") + if not param: + param = "" + + bar = param + + import hashlib, base64 + import io, helpers.utils + + input = '' + if isinstance(bar, str): + input = bar.encode('utf-8') + elif isinstance(bar, io.IOBase): + input = bar.read(1000) + + if len(input) == 0: + RESPONSE += ( + 'Cannot generate hash: Input was empty.' + ) + return RESPONSE + + hash = hashlib.sha512() + hash.update(input) + + result = hash.digest() + f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + f.write(f'hash_value={base64.b64encode(result)}\n') + RESPONSE += ( + f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.' + ) + f.close() + + return RESPONSE + diff --git a/Samples/BenchmarkTest00162.py b/Samples/BenchmarkTest00162.py new file mode 100644 index 0000000..e10ab6b --- /dev/null +++ b/Samples/BenchmarkTest00162.py @@ -0,0 +1,62 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/codeinj-00/BenchmarkTest00162', methods=['GET']) + def BenchmarkTest00162_get(): + return BenchmarkTest00162_post() + + @app.route('/benchmark/codeinj-00/BenchmarkTest00162', methods=['POST']) + def BenchmarkTest00162_post(): + RESPONSE = "" + + param = request.form.get("BenchmarkTest00162") + if not param: + param = "" + + possible = "ABC" + guess = possible[1] + + match guess: + case 'A': + bar = param + case 'B': + bar = 'bob' + case 'C' | 'D': + bar = param + case _: + bar = 'bob\'s your uncle' + + if not bar.startswith('\'') or not bar.endswith('\'') or '\'' in bar[1:-1]: + RESPONSE += ( + "Exec argument must be a plain string literal." + ) + return RESPONSE + + try: + exec(bar) + except: + RESPONSE += ( + f'Error executing statement \'{escape_for_html(bar)}\'' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00164.py b/Samples/BenchmarkTest00164.py new file mode 100644 index 0000000..60a75d0 --- /dev/null +++ b/Samples/BenchmarkTest00164.py @@ -0,0 +1,59 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/deserialization-00/BenchmarkTest00164', methods=['GET']) + def BenchmarkTest00164_get(): + return BenchmarkTest00164_post() + + @app.route('/benchmark/deserialization-00/BenchmarkTest00164', methods=['POST']) + def BenchmarkTest00164_post(): + RESPONSE = "" + + param = request.form.get("BenchmarkTest00164") + if not param: + param = "" + + string6880 = 'help' + string6880 += param + string6880 += 'snapes on a plane' + bar = string6880[4:-17] + + import pickle + import base64 + import helpers.utils + + helpers.utils.sharedstr = "no pickles to be seen here" + + try: + unpickled = pickle.loads(base64.urlsafe_b64decode(bar)) + except: + RESPONSE += ( + 'Unpickling failed!' + ) + return RESPONSE + + RESPONSE += ( + f'shared string is {helpers.utils.sharedstr}' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00176.py b/Samples/BenchmarkTest00176.py new file mode 100644 index 0000000..07bcf80 --- /dev/null +++ b/Samples/BenchmarkTest00176.py @@ -0,0 +1,70 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/pathtraver-00/BenchmarkTest00176', methods=['GET']) + def BenchmarkTest00176_get(): + return BenchmarkTest00176_post() + + @app.route('/benchmark/pathtraver-00/BenchmarkTest00176', methods=['POST']) + def BenchmarkTest00176_post(): + RESPONSE = "" + + values = request.form.getlist("BenchmarkTest00176") + param = "" + if values: + param = values[0] + + possible = "ABC" + guess = possible[1] + + match guess: + case 'A': + bar = param + case 'B': + bar = 'bob' + case 'C' | 'D': + bar = param + case _: + bar = 'bob\'s your uncle' + + import helpers.utils + + try: + fileName = f'{helpers.utils.TESTFILES_DIR}/{bar}' + fd = open(fileName, 'wb') + RESPONSE += ( + f'Now ready to write to file: {escape_for_html(fileName)}' + ) + except IOError as e: + RESPONSE += ( + f'Problem reading from file \'{escape_for_html(fileName)}\': ' + f'{escape_for_html(e.strerror)}' + ) + finally: + try: + if fd is not None: + fd.close() + except IOError: + pass # "// we tried..." + + return RESPONSE + diff --git a/Samples/BenchmarkTest00179.py b/Samples/BenchmarkTest00179.py new file mode 100644 index 0000000..4028bf7 --- /dev/null +++ b/Samples/BenchmarkTest00179.py @@ -0,0 +1,55 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/pathtraver-00/BenchmarkTest00179', methods=['GET']) + def BenchmarkTest00179_get(): + return BenchmarkTest00179_post() + + @app.route('/benchmark/pathtraver-00/BenchmarkTest00179', methods=['POST']) + def BenchmarkTest00179_post(): + RESPONSE = "" + + values = request.form.getlist("BenchmarkTest00179") + param = "" + if values: + param = values[0] + + bar = "alsosafe" + if param: + lst = [] + lst.append('safe') + lst.append(param) + lst.append('moresafe') + lst.pop(0) + bar = lst[1] + + import os + import helpers.utils + + fileName = f'{helpers.utils.TESTFILES_DIR}/{bar}' + if os.path.exists(fileName): + RESPONSE += ( f"File \'{escape_for_html(fileName)}\' exists." ) + else: + RESPONSE += ( f"File \'{escape_for_html(fileName)}\' does not exist." ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00187.py b/Samples/BenchmarkTest00187.py new file mode 100644 index 0000000..13181aa --- /dev/null +++ b/Samples/BenchmarkTest00187.py @@ -0,0 +1,47 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xss-00/BenchmarkTest00187', methods=['GET']) + def BenchmarkTest00187_get(): + return BenchmarkTest00187_post() + + @app.route('/benchmark/xss-00/BenchmarkTest00187', methods=['POST']) + def BenchmarkTest00187_post(): + RESPONSE = "" + + values = request.form.getlist("BenchmarkTest00187") + param = "" + if values: + param = values[0] + + import base64 + tmp = base64.b64encode(param.encode('utf-8')) + bar = base64.b64decode(tmp).decode('utf-8') + + + otherarg = "static text" + RESPONSE += ( + 'bar is \'{0}\' and otherarg is \'{1}\''.format(bar, otherarg) + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00190.py b/Samples/BenchmarkTest00190.py new file mode 100644 index 0000000..b4a106d --- /dev/null +++ b/Samples/BenchmarkTest00190.py @@ -0,0 +1,47 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xss-00/BenchmarkTest00190', methods=['GET']) + def BenchmarkTest00190_get(): + return BenchmarkTest00190_post() + + @app.route('/benchmark/xss-00/BenchmarkTest00190', methods=['POST']) + def BenchmarkTest00190_post(): + RESPONSE = "" + + values = request.form.getlist("BenchmarkTest00190") + param = "" + if values: + param = values[0] + + import html + + bar = html.escape(param) + + + otherarg = "static text" + RESPONSE += ( + 'bar is \'%s\' and otherarg is \'%s\'' % (bar, otherarg) + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00192.py b/Samples/BenchmarkTest00192.py new file mode 100644 index 0000000..b61300a --- /dev/null +++ b/Samples/BenchmarkTest00192.py @@ -0,0 +1,61 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/sqli-00/BenchmarkTest00192', methods=['GET']) + def BenchmarkTest00192_get(): + return BenchmarkTest00192_post() + + @app.route('/benchmark/sqli-00/BenchmarkTest00192', methods=['POST']) + def BenchmarkTest00192_post(): + RESPONSE = "" + + values = request.form.getlist("BenchmarkTest00192") + param = "" + if values: + param = values[0] + + possible = "ABC" + guess = possible[1] + + match guess: + case 'A': + bar = param + case 'B': + bar = 'bob' + case 'C' | 'D': + bar = param + case _: + bar = 'bob\'s your uncle' + + import helpers.db_sqlite + + sql = f'SELECT username from USERS where password = ?' + con = helpers.db_sqlite.get_connection() + cur = con.cursor() + cur.execute(sql, (bar,)) + RESPONSE += ( + helpers.db_sqlite.results(cur, sql) + ) + con.close() + + return RESPONSE + diff --git a/Samples/BenchmarkTest00194.py b/Samples/BenchmarkTest00194.py new file mode 100644 index 0000000..6882853 --- /dev/null +++ b/Samples/BenchmarkTest00194.py @@ -0,0 +1,64 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xpathi-00/BenchmarkTest00194', methods=['GET']) + def BenchmarkTest00194_get(): + return BenchmarkTest00194_post() + + @app.route('/benchmark/xpathi-00/BenchmarkTest00194', methods=['POST']) + def BenchmarkTest00194_post(): + RESPONSE = "" + + values = request.form.getlist("BenchmarkTest00194") + param = "" + if values: + param = values[0] + + num = 86 + + if 7 * 42 - num > 200: + bar = 'This_should_always_happen' + else: + bar = param + + import elementpath + import xml.etree.ElementTree as ET + import helpers.utils + + try: + root = ET.parse(f'{helpers.utils.RES_DIR}/employees.xml') + query = f"/Employees/Employee[@emplid=\'{bar}\']" + nodes = elementpath.select(root, query) + node_strings = [] + for node in nodes: + node_strings.append(' '.join([e.text for e in node])) + + RESPONSE += ( + f'Your XPATH query results are:
[ {', '.join(node_strings)} ]' + ) + except: + RESPONSE += ( + f'Error parsing XPath Query: \'{escape_for_html(query)}\'' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00199.py b/Samples/BenchmarkTest00199.py new file mode 100644 index 0000000..59af28d --- /dev/null +++ b/Samples/BenchmarkTest00199.py @@ -0,0 +1,59 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xpathi-00/BenchmarkTest00199', methods=['GET']) + def BenchmarkTest00199_get(): + return BenchmarkTest00199_post() + + @app.route('/benchmark/xpathi-00/BenchmarkTest00199', methods=['POST']) + def BenchmarkTest00199_post(): + RESPONSE = "" + + values = request.form.getlist("BenchmarkTest00199") + param = "" + if values: + param = values[0] + + bar = param + + import elementpath + import xml.etree.ElementTree as ET + import helpers.utils + + try: + root = ET.parse(f'{helpers.utils.RES_DIR}/employees.xml') + nodes = elementpath.select(root, f"/Employees/Employee[@emplid=\'{bar.replace('\'', ''')}\']") + node_strings = [] + for node in nodes: + node_strings.append(' '.join([e.text for e in node])) + + RESPONSE += ( + f'Your XPATH query results are:
[ {', '.join(node_strings)} ]' + ) + except: + RESPONSE += ( + f'Error parsing XPath Query: \'{escape_for_html(query)}\'' + ) + + + return RESPONSE + diff --git a/Samples/BenchmarkTest00202.py b/Samples/BenchmarkTest00202.py new file mode 100644 index 0000000..b820c14 --- /dev/null +++ b/Samples/BenchmarkTest00202.py @@ -0,0 +1,61 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xpathi-00/BenchmarkTest00202', methods=['GET']) + def BenchmarkTest00202_get(): + return BenchmarkTest00202_post() + + @app.route('/benchmark/xpathi-00/BenchmarkTest00202', methods=['POST']) + def BenchmarkTest00202_post(): + RESPONSE = "" + + values = request.form.getlist("BenchmarkTest00202") + param = "" + if values: + param = values[0] + + num = 106 + + bar = "This should never happen" if (7*42) - num > 200 else param + + import elementpath + import xml.etree.ElementTree as ET + import helpers.utils + + try: + root = ET.parse(f'{helpers.utils.RES_DIR}/employees.xml') + nodes = elementpath.select(root, f"/Employees/Employee[@emplid=\'{bar.replace('\'', ''')}\']") + node_strings = [] + for node in nodes: + node_strings.append(' '.join([e.text for e in node])) + + RESPONSE += ( + f'Your XPATH query results are:
[ {', '.join(node_strings)} ]' + ) + except: + RESPONSE += ( + f'Error parsing XPath Query: \'{escape_for_html(query)}\'' + ) + + + return RESPONSE + diff --git a/Samples/BenchmarkTest00207.py b/Samples/BenchmarkTest00207.py new file mode 100644 index 0000000..44a8b20 --- /dev/null +++ b/Samples/BenchmarkTest00207.py @@ -0,0 +1,70 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xpathi-00/BenchmarkTest00207', methods=['GET']) + def BenchmarkTest00207_get(): + return BenchmarkTest00207_post() + + @app.route('/benchmark/xpathi-00/BenchmarkTest00207', methods=['POST']) + def BenchmarkTest00207_post(): + RESPONSE = "" + + values = request.form.getlist("BenchmarkTest00207") + param = "" + if values: + param = values[0] + + possible = "ABC" + guess = possible[0] + + match guess: + case 'A': + bar = param + case 'B': + bar = 'bob' + case 'C' | 'D': + bar = param + case _: + bar = 'bob\'s your uncle' + + import lxml.etree + import helpers.utils + + try: + fd = open(f'{helpers.utils.RES_DIR}/employees.xml', 'rb') + root = lxml.etree.parse(fd) + query = f'/Employees/Employee[@emplid=\'{bar}\']' + nodes = root.xpath(query) + node_strings = [] + for node in nodes: + node_strings.append(' '.join([e.text for e in node])) + + RESPONSE += ( + f'Your XPATH query results are:
[ {', '.join(node_strings)} ]' + ) + except: + RESPONSE += ( + f'Error parsing XPath Query: \'{escape_for_html(query)}\'' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00210.py b/Samples/BenchmarkTest00210.py new file mode 100644 index 0000000..0faf686 --- /dev/null +++ b/Samples/BenchmarkTest00210.py @@ -0,0 +1,64 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xpathi-00/BenchmarkTest00210', methods=['GET']) + def BenchmarkTest00210_get(): + return BenchmarkTest00210_post() + + @app.route('/benchmark/xpathi-00/BenchmarkTest00210', methods=['POST']) + def BenchmarkTest00210_post(): + RESPONSE = "" + + values = request.form.getlist("BenchmarkTest00210") + param = "" + if values: + param = values[0] + + TestParam = "This should never happen" + if 'should' not in TestParam: + bar = "Ifnot case passed" + else: + bar = param + + import lxml.etree + import helpers.utils + + try: + fd = open(f'{helpers.utils.RES_DIR}/employees.xml', 'rb') + root = lxml.etree.parse(fd) + query = '/Employees/Employee[@emplid=\'' + bar + '\']' + + nodes = root.xpath(query) + node_strings = [] + for node in nodes: + node_strings.append(' '.join([e.text for e in node])) + + RESPONSE += ( + f'Your XPATH query results are:
[ {', '.join(node_strings)} ]' + ) + except: + RESPONSE += ( + f'Error parsing XPath Query: \'{escape_for_html(query)}\'' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00218.py b/Samples/BenchmarkTest00218.py new file mode 100644 index 0000000..0d40372 --- /dev/null +++ b/Samples/BenchmarkTest00218.py @@ -0,0 +1,69 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-00/BenchmarkTest00218', methods=['GET']) + def BenchmarkTest00218_get(): + return BenchmarkTest00218_post() + + @app.route('/benchmark/weakrand-00/BenchmarkTest00218', methods=['POST']) + def BenchmarkTest00218_post(): + RESPONSE = "" + + values = request.form.getlist("BenchmarkTest00218") + param = "" + if values: + param = values[0] + + possible = "ABC" + guess = possible[1] + + match guess: + case 'A': + bar = param + case 'B': + bar = 'bob' + case 'C' | 'D': + bar = param + case _: + bar = 'bob\'s your uncle' + + import random + from helpers.utils import mysession + + num = 'BenchmarkTest00218'[13:] + user = f'Nancy{num}' + cookie = f'rememberMe{num}' + value = str(random.normalvariate())[2:] + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie: ' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00224.py b/Samples/BenchmarkTest00224.py new file mode 100644 index 0000000..050d111 --- /dev/null +++ b/Samples/BenchmarkTest00224.py @@ -0,0 +1,58 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-00/BenchmarkTest00224', methods=['GET']) + def BenchmarkTest00224_get(): + return BenchmarkTest00224_post() + + @app.route('/benchmark/weakrand-00/BenchmarkTest00224', methods=['POST']) + def BenchmarkTest00224_post(): + RESPONSE = "" + + values = request.form.getlist("BenchmarkTest00224") + param = "" + if values: + param = values[0] + + bar = param + + import random + from helpers.utils import mysession + + num = 'BenchmarkTest00224'[13:] + user = f'Randall{num}' + cookie = f'rememberMe{num}' + value = str(random.random())[2:] + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie: ' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00225.py b/Samples/BenchmarkTest00225.py new file mode 100644 index 0000000..1d1e8e0 --- /dev/null +++ b/Samples/BenchmarkTest00225.py @@ -0,0 +1,65 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-00/BenchmarkTest00225', methods=['GET']) + def BenchmarkTest00225_get(): + return BenchmarkTest00225_post() + + @app.route('/benchmark/weakrand-00/BenchmarkTest00225', methods=['POST']) + def BenchmarkTest00225_post(): + RESPONSE = "" + + values = request.form.getlist("BenchmarkTest00225") + param = "" + if values: + param = values[0] + + import configparser + + bar = 'safe!' + conf54571 = configparser.ConfigParser() + conf54571.add_section('section54571') + conf54571.set('section54571', 'keyA-54571', 'a_Value') + conf54571.set('section54571', 'keyB-54571', param) + bar = conf54571.get('section54571', 'keyA-54571') + + import random + from helpers.utils import mysession + + num = 'BenchmarkTest00225'[13:] + user = f'Randall{num}' + cookie = f'rememberMe{num}' + value = str(random.random())[2:] + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie: ' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00229.py b/Samples/BenchmarkTest00229.py new file mode 100644 index 0000000..acf0ce3 --- /dev/null +++ b/Samples/BenchmarkTest00229.py @@ -0,0 +1,60 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-00/BenchmarkTest00229', methods=['GET']) + def BenchmarkTest00229_get(): + return BenchmarkTest00229_post() + + @app.route('/benchmark/weakrand-00/BenchmarkTest00229', methods=['POST']) + def BenchmarkTest00229_post(): + RESPONSE = "" + + values = request.form.getlist("BenchmarkTest00229") + param = "" + if values: + param = values[0] + + bar = "This should never happen" + if 'should' in bar: + bar = param + + import secrets + from helpers.utils import mysession + + num = 'BenchmarkTest00229'[13:] + user = f'SafeRobbie{num}' + cookie = f'rememberMe{num}' + value = str(secrets.randbelow(2**32)) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie:' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00230.py b/Samples/BenchmarkTest00230.py new file mode 100644 index 0000000..6ba3f2a --- /dev/null +++ b/Samples/BenchmarkTest00230.py @@ -0,0 +1,58 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-00/BenchmarkTest00230', methods=['GET']) + def BenchmarkTest00230_get(): + return BenchmarkTest00230_post() + + @app.route('/benchmark/weakrand-00/BenchmarkTest00230', methods=['POST']) + def BenchmarkTest00230_post(): + RESPONSE = "" + + values = request.form.getlist("BenchmarkTest00230") + param = "" + if values: + param = values[0] + + bar = param + '_SafeStuff' + + import secrets + from helpers.utils import mysession + + num = 'BenchmarkTest00230'[13:] + user = f'SafeRobbie{num}' + cookie = f'rememberMe{num}' + value = str(secrets.randbelow(2**32)) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie:' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00235.py b/Samples/BenchmarkTest00235.py new file mode 100644 index 0000000..c83f0d7 --- /dev/null +++ b/Samples/BenchmarkTest00235.py @@ -0,0 +1,61 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-00/BenchmarkTest00235', methods=['GET']) + def BenchmarkTest00235_get(): + return BenchmarkTest00235_post() + + @app.route('/benchmark/weakrand-00/BenchmarkTest00235', methods=['POST']) + def BenchmarkTest00235_post(): + RESPONSE = "" + + values = request.form.getlist("BenchmarkTest00235") + param = "" + if values: + param = values[0] + + bar = '' + if param: + bar = param.split(' ')[0] + + import base64 + import secrets + from helpers.utils import mysession + + num = 'BenchmarkTest00235'[13:] + user = f'SafeTruman{num}' + cookie = f'rememberMe{num}' + value = secrets.token_urlsafe(32) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie:' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00248.py b/Samples/BenchmarkTest00248.py new file mode 100644 index 0000000..9fc148e --- /dev/null +++ b/Samples/BenchmarkTest00248.py @@ -0,0 +1,72 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/hash-00/BenchmarkTest00248', methods=['GET']) + def BenchmarkTest00248_get(): + return BenchmarkTest00248_post() + + @app.route('/benchmark/hash-00/BenchmarkTest00248', methods=['POST']) + def BenchmarkTest00248_post(): + RESPONSE = "" + + values = request.form.getlist("BenchmarkTest00248") + param = "" + if values: + param = values[0] + + import configparser + + bar = 'safe!' + conf78480 = configparser.ConfigParser() + conf78480.add_section('section78480') + conf78480.set('section78480', 'keyA-78480', 'a_Value') + conf78480.set('section78480', 'keyB-78480', param) + bar = conf78480.get('section78480', 'keyA-78480') + + import hashlib, base64 + import io, helpers.utils + + input = '' + if isinstance(bar, str): + input = bar.encode('utf-8') + elif isinstance(bar, io.IOBase): + input = bar.read(1000) + + if len(input) == 0: + RESPONSE += ( + 'Cannot generate hash: Input was empty.' + ) + return RESPONSE + + hash = hashlib.md5() + hash.update(input) + + result = hash.digest() + f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + f.write(f'hash_value={base64.b64encode(result)}\n') + RESPONSE += ( + f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.' + ) + f.close() + + return RESPONSE + diff --git a/Samples/BenchmarkTest00256.py b/Samples/BenchmarkTest00256.py new file mode 100644 index 0000000..34502c9 --- /dev/null +++ b/Samples/BenchmarkTest00256.py @@ -0,0 +1,52 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xss-00/BenchmarkTest00256', methods=['GET']) + def BenchmarkTest00256_get(): + return BenchmarkTest00256_post() + + @app.route('/benchmark/xss-00/BenchmarkTest00256', methods=['POST']) + def BenchmarkTest00256_post(): + RESPONSE = "" + + values = request.form.getlist("BenchmarkTest00256") + param = "" + if values: + param = values[0] + + num = 86 + + if 7 * 42 - num > 200: + bar = 'This_should_always_happen' + else: + bar = param + + + RESPONSE += ( + 'The value of the bar parameter is now in a custom header.' + ) + + RESPONSE = make_response((RESPONSE, {'yourBenchmarkTest00256': bar})) + + + return RESPONSE + diff --git a/Samples/BenchmarkTest00258.py b/Samples/BenchmarkTest00258.py new file mode 100644 index 0000000..401d534 --- /dev/null +++ b/Samples/BenchmarkTest00258.py @@ -0,0 +1,43 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/redirect-00/BenchmarkTest00258', methods=['GET']) + def BenchmarkTest00258_get(): + return BenchmarkTest00258_post() + + @app.route('/benchmark/redirect-00/BenchmarkTest00258', methods=['POST']) + def BenchmarkTest00258_post(): + RESPONSE = "" + + values = request.form.getlist("BenchmarkTest00258") + param = "" + if values: + param = values[0] + + bar = param + + import flask + + return flask.redirect(bar) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00263.py b/Samples/BenchmarkTest00263.py new file mode 100644 index 0000000..5d37743 --- /dev/null +++ b/Samples/BenchmarkTest00263.py @@ -0,0 +1,59 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/codeinj-00/BenchmarkTest00263', methods=['GET']) + def BenchmarkTest00263_get(): + return BenchmarkTest00263_post() + + @app.route('/benchmark/codeinj-00/BenchmarkTest00263', methods=['POST']) + def BenchmarkTest00263_post(): + RESPONSE = "" + + values = request.form.getlist("BenchmarkTest00263") + param = "" + if values: + param = values[0] + + possible = "ABC" + guess = possible[1] + + match guess: + case 'A': + bar = param + case 'B': + bar = 'bob' + case 'C' | 'D': + bar = param + case _: + bar = 'bob\'s your uncle' + + try: + RESPONSE += ( + eval(bar) + ) + except: + RESPONSE += ( + f'Error evaluating expression \'{escape_for_html(bar)}\'' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00271.py b/Samples/BenchmarkTest00271.py new file mode 100644 index 0000000..d3937ee --- /dev/null +++ b/Samples/BenchmarkTest00271.py @@ -0,0 +1,63 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/deserialization-00/BenchmarkTest00271', methods=['GET']) + def BenchmarkTest00271_get(): + return BenchmarkTest00271_post() + + @app.route('/benchmark/deserialization-00/BenchmarkTest00271', methods=['POST']) + def BenchmarkTest00271_post(): + RESPONSE = "" + + values = request.form.getlist("BenchmarkTest00271") + param = "" + if values: + param = values[0] + + possible = "ABC" + guess = possible[0] + + match guess: + case 'A': + bar = param + case 'B': + bar = 'bob' + case 'C' | 'D': + bar = param + case _: + bar = 'bob\'s your uncle' + + import yaml + + try: + yobj = yaml.safe_load(bar) + + RESPONSE += ( + yobj['text'] + ) + except: + RESPONSE += ( + "There was an error loading the configuration" + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00284.py b/Samples/BenchmarkTest00284.py new file mode 100644 index 0000000..9d98c1a --- /dev/null +++ b/Samples/BenchmarkTest00284.py @@ -0,0 +1,54 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/sqli-00/BenchmarkTest00284', methods=['GET']) + def BenchmarkTest00284_get(): + return BenchmarkTest00284_post() + + @app.route('/benchmark/sqli-00/BenchmarkTest00284', methods=['POST']) + def BenchmarkTest00284_post(): + RESPONSE = "" + + import helpers.separate_request + + wrapped = helpers.separate_request.request_wrapper(request) + param = wrapped.get_form_parameter("BenchmarkTest00284") + if not param: + param = "" + + bar = "This should never happen" + if 'should' in bar: + bar = param + + import helpers.db_sqlite + + sql = f'SELECT username from USERS where password = \'{bar}\'' + con = helpers.db_sqlite.get_connection() + cur = con.cursor() + cur.execute(sql) + RESPONSE += ( + helpers.db_sqlite.results(cur, sql) + ) + con.close() + + return RESPONSE + diff --git a/Samples/BenchmarkTest00286.py b/Samples/BenchmarkTest00286.py new file mode 100644 index 0000000..fc0ecd5 --- /dev/null +++ b/Samples/BenchmarkTest00286.py @@ -0,0 +1,59 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/sqli-00/BenchmarkTest00286', methods=['GET']) + def BenchmarkTest00286_get(): + return BenchmarkTest00286_post() + + @app.route('/benchmark/sqli-00/BenchmarkTest00286', methods=['POST']) + def BenchmarkTest00286_post(): + RESPONSE = "" + + import helpers.separate_request + + wrapped = helpers.separate_request.request_wrapper(request) + param = wrapped.get_form_parameter("BenchmarkTest00286") + if not param: + param = "" + + import configparser + + bar = 'safe!' + conf59255 = configparser.ConfigParser() + conf59255.add_section('section59255') + conf59255.set('section59255', 'keyA-59255', 'a_Value') + conf59255.set('section59255', 'keyB-59255', param) + bar = conf59255.get('section59255', 'keyA-59255') + + import helpers.db_sqlite + + sql = f'SELECT username from USERS where password = ?' + con = helpers.db_sqlite.get_connection() + cur = con.cursor() + cur.execute(sql, (bar,)) + RESPONSE += ( + helpers.db_sqlite.results(cur, sql) + ) + con.close() + + return RESPONSE + diff --git a/Samples/BenchmarkTest00293.py b/Samples/BenchmarkTest00293.py new file mode 100644 index 0000000..bd6d9e1 --- /dev/null +++ b/Samples/BenchmarkTest00293.py @@ -0,0 +1,69 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xxe-00/BenchmarkTest00293', methods=['GET']) + def BenchmarkTest00293_get(): + return BenchmarkTest00293_post() + + @app.route('/benchmark/xxe-00/BenchmarkTest00293', methods=['POST']) + def BenchmarkTest00293_post(): + RESPONSE = "" + + import helpers.separate_request + + wrapped = helpers.separate_request.request_wrapper(request) + param = wrapped.get_form_parameter("BenchmarkTest00293") + if not param: + param = "" + + num = 106 + + bar = "This should never happen" if (7*42) - num > 200 else param + + import xml.dom.minidom + import xml.sax.handler + + try: + parser = xml.sax.make_parser() + # all features are disabled by default + + doc = xml.dom.minidom.parseString(bar, parser) + + out = '' + processing = [doc.documentElement] + while processing: + e = processing.pop(0) + if e.nodeType == xml.dom.Node.TEXT_NODE: + out += e.data + else: + processing[:0] = e.childNodes + + RESPONSE += ( + f'Your XML doc results are:
{escape_for_html(out)}' + ) + except: + RESPONSE += ( + f'There was an error reading your XML doc:
{escape_for_html(bar)}' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00314.py b/Samples/BenchmarkTest00314.py new file mode 100644 index 0000000..2bf37c7 --- /dev/null +++ b/Samples/BenchmarkTest00314.py @@ -0,0 +1,65 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-01/BenchmarkTest00314', methods=['GET']) + def BenchmarkTest00314_get(): + return BenchmarkTest00314_post() + + @app.route('/benchmark/weakrand-01/BenchmarkTest00314', methods=['POST']) + def BenchmarkTest00314_post(): + RESPONSE = "" + + import helpers.separate_request + + wrapped = helpers.separate_request.request_wrapper(request) + param = wrapped.get_form_parameter("BenchmarkTest00314") + if not param: + param = "" + + num = 86 + + if 7 * 42 - num > 200: + bar = 'This_should_always_happen' + else: + bar = param + + import random + from helpers.utils import mysession + + num = 'BenchmarkTest00314'[13:] + user = f'SafeRandy{num}' + cookie = f'rememberMe{num}' + value = str(random.SystemRandom().getrandbits(32)) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie: ' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00319.py b/Samples/BenchmarkTest00319.py new file mode 100644 index 0000000..6b3e41d --- /dev/null +++ b/Samples/BenchmarkTest00319.py @@ -0,0 +1,68 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/hash-00/BenchmarkTest00319', methods=['GET']) + def BenchmarkTest00319_get(): + return BenchmarkTest00319_post() + + @app.route('/benchmark/hash-00/BenchmarkTest00319', methods=['POST']) + def BenchmarkTest00319_post(): + RESPONSE = "" + + import helpers.separate_request + + wrapped = helpers.separate_request.request_wrapper(request) + param = wrapped.get_form_parameter("BenchmarkTest00319") + if not param: + param = "" + + import helpers.utils + bar = helpers.utils.escape_for_html(param) + + import hashlib, base64 + import io, helpers.utils + + input = '' + if isinstance(bar, str): + input = bar.encode('utf-8') + elif isinstance(bar, io.IOBase): + input = bar.read(1000) + + if len(input) == 0: + RESPONSE += ( + 'Cannot generate hash: Input was empty.' + ) + return RESPONSE + + hash = hashlib.new('md5') + hash.update(input) + + result = hash.digest() + f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + f.write(f'hash_value={base64.b64encode(result)}\n') + RESPONSE += ( + f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.' + ) + f.close() + + return RESPONSE + diff --git a/Samples/BenchmarkTest00324.py b/Samples/BenchmarkTest00324.py new file mode 100644 index 0000000..5483fd2 --- /dev/null +++ b/Samples/BenchmarkTest00324.py @@ -0,0 +1,67 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/hash-00/BenchmarkTest00324', methods=['GET']) + def BenchmarkTest00324_get(): + return BenchmarkTest00324_post() + + @app.route('/benchmark/hash-00/BenchmarkTest00324', methods=['POST']) + def BenchmarkTest00324_post(): + RESPONSE = "" + + import helpers.separate_request + + wrapped = helpers.separate_request.request_wrapper(request) + param = wrapped.get_form_parameter("BenchmarkTest00324") + if not param: + param = "" + + bar = param + + import hashlib, base64 + import io, helpers.utils + + input = '' + if isinstance(bar, str): + input = bar.encode('utf-8') + elif isinstance(bar, io.IOBase): + input = bar.read(1000) + + if len(input) == 0: + RESPONSE += ( + 'Cannot generate hash: Input was empty.' + ) + return RESPONSE + + hash = hashlib.new('sha512') + hash.update(input) + + result = hash.digest() + f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + f.write(f'hash_value={base64.b64encode(result)}\n') + RESPONSE += ( + f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.' + ) + f.close() + + return RESPONSE + diff --git a/Samples/BenchmarkTest00327.py b/Samples/BenchmarkTest00327.py new file mode 100644 index 0000000..ef11a0b --- /dev/null +++ b/Samples/BenchmarkTest00327.py @@ -0,0 +1,74 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/hash-00/BenchmarkTest00327', methods=['GET']) + def BenchmarkTest00327_get(): + return BenchmarkTest00327_post() + + @app.route('/benchmark/hash-00/BenchmarkTest00327', methods=['POST']) + def BenchmarkTest00327_post(): + RESPONSE = "" + + import helpers.separate_request + + wrapped = helpers.separate_request.request_wrapper(request) + param = wrapped.get_form_parameter("BenchmarkTest00327") + if not param: + param = "" + + import configparser + + bar = 'safe!' + conf75704 = configparser.ConfigParser() + conf75704.add_section('section75704') + conf75704.set('section75704', 'keyA-75704', 'a_Value') + conf75704.set('section75704', 'keyB-75704', param) + bar = conf75704.get('section75704', 'keyA-75704') + + import hashlib, base64 + import io, helpers.utils + + input = '' + if isinstance(bar, str): + input = bar.encode('utf-8') + elif isinstance(bar, io.IOBase): + input = bar.read(1000) + + if len(input) == 0: + RESPONSE += ( + 'Cannot generate hash: Input was empty.' + ) + return RESPONSE + + hash = hashlib.md5() + hash.update(input) + + result = hash.digest() + f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + f.write(f'hash_value={base64.b64encode(result)}\n') + RESPONSE += ( + f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.' + ) + f.close() + + return RESPONSE + diff --git a/Samples/BenchmarkTest00328.py b/Samples/BenchmarkTest00328.py new file mode 100644 index 0000000..c460592 --- /dev/null +++ b/Samples/BenchmarkTest00328.py @@ -0,0 +1,67 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/hash-00/BenchmarkTest00328', methods=['GET']) + def BenchmarkTest00328_get(): + return BenchmarkTest00328_post() + + @app.route('/benchmark/hash-00/BenchmarkTest00328', methods=['POST']) + def BenchmarkTest00328_post(): + RESPONSE = "" + + import helpers.separate_request + + wrapped = helpers.separate_request.request_wrapper(request) + param = wrapped.get_form_parameter("BenchmarkTest00328") + if not param: + param = "" + + bar = param + + import hashlib, base64 + import io, helpers.utils + + input = '' + if isinstance(bar, str): + input = bar.encode('utf-8') + elif isinstance(bar, io.IOBase): + input = bar.read(1000) + + if len(input) == 0: + RESPONSE += ( + 'Cannot generate hash: Input was empty.' + ) + return RESPONSE + + hash = hashlib.sha1() + hash.update(input) + + result = hash.digest() + f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + f.write(f'hash_value={base64.b64encode(result)}\n') + RESPONSE += ( + f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.' + ) + f.close() + + return RESPONSE + diff --git a/Samples/BenchmarkTest00331.py b/Samples/BenchmarkTest00331.py new file mode 100644 index 0000000..62415a1 --- /dev/null +++ b/Samples/BenchmarkTest00331.py @@ -0,0 +1,68 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/hash-00/BenchmarkTest00331', methods=['GET']) + def BenchmarkTest00331_get(): + return BenchmarkTest00331_post() + + @app.route('/benchmark/hash-00/BenchmarkTest00331', methods=['POST']) + def BenchmarkTest00331_post(): + RESPONSE = "" + + import helpers.separate_request + + wrapped = helpers.separate_request.request_wrapper(request) + param = wrapped.get_form_parameter("BenchmarkTest00331") + if not param: + param = "" + + import helpers.utils + bar = helpers.utils.escape_for_html(param) + + import hashlib, base64 + import io, helpers.utils + + input = '' + if isinstance(bar, str): + input = bar.encode('utf-8') + elif isinstance(bar, io.IOBase): + input = bar.read(1000) + + if len(input) == 0: + RESPONSE += ( + 'Cannot generate hash: Input was empty.' + ) + return RESPONSE + + hash = hashlib.sha512() + hash.update(input) + + result = hash.digest() + f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + f.write(f'hash_value={base64.b64encode(result)}\n') + RESPONSE += ( + f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.' + ) + f.close() + + return RESPONSE + diff --git a/Samples/BenchmarkTest00334.py b/Samples/BenchmarkTest00334.py new file mode 100644 index 0000000..fe3113c --- /dev/null +++ b/Samples/BenchmarkTest00334.py @@ -0,0 +1,53 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xss-00/BenchmarkTest00334', methods=['GET']) + def BenchmarkTest00334_get(): + return BenchmarkTest00334_post() + + @app.route('/benchmark/xss-00/BenchmarkTest00334', methods=['POST']) + def BenchmarkTest00334_post(): + RESPONSE = "" + + import helpers.separate_request + + wrapped = helpers.separate_request.request_wrapper(request) + param = wrapped.get_form_parameter("BenchmarkTest00334") + if not param: + param = "" + + TestParam = "This should never happen" + if 'should' not in TestParam: + bar = "Ifnot case passed" + else: + bar = param + + + RESPONSE += ( + 'The value of the bar parameter is now in a custom header.' + ) + + RESPONSE = make_response((RESPONSE, {'yourBenchmarkTest00334': bar})) + + + return RESPONSE + diff --git a/Samples/BenchmarkTest00335.py b/Samples/BenchmarkTest00335.py new file mode 100644 index 0000000..78cfcd3 --- /dev/null +++ b/Samples/BenchmarkTest00335.py @@ -0,0 +1,54 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xss-00/BenchmarkTest00335', methods=['GET']) + def BenchmarkTest00335_get(): + return BenchmarkTest00335_post() + + @app.route('/benchmark/xss-00/BenchmarkTest00335', methods=['POST']) + def BenchmarkTest00335_post(): + RESPONSE = "" + + import helpers.separate_request + + wrapped = helpers.separate_request.request_wrapper(request) + param = wrapped.get_form_parameter("BenchmarkTest00335") + if not param: + param = "" + + num = 86 + + if 7 * 42 - num > 200: + bar = 'This_should_always_happen' + else: + bar = param + + + RESPONSE += ( + 'The value of the bar parameter is now in a custom header.' + ) + + RESPONSE = make_response((RESPONSE, {'yourBenchmarkTest00335': bar})) + + + return RESPONSE + diff --git a/Samples/BenchmarkTest00339.py b/Samples/BenchmarkTest00339.py new file mode 100644 index 0000000..baa9e9b --- /dev/null +++ b/Samples/BenchmarkTest00339.py @@ -0,0 +1,55 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/trustbound-00/BenchmarkTest00339', methods=['GET']) + def BenchmarkTest00339_get(): + return BenchmarkTest00339_post() + + @app.route('/benchmark/trustbound-00/BenchmarkTest00339', methods=['POST']) + def BenchmarkTest00339_post(): + RESPONSE = "" + + import helpers.separate_request + + wrapped = helpers.separate_request.request_wrapper(request) + param = wrapped.get_form_parameter("BenchmarkTest00339") + if not param: + param = "" + + num = 86 + + if 7 * 42 - num > 200: + bar = 'This_should_always_happen' + else: + bar = param + + import flask + + flask.session['userid'] = bar + + RESPONSE += ( + f'Item: \'userid\' with value \'{escape_for_html(bar)}' + '\'saved in session.' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00351.py b/Samples/BenchmarkTest00351.py new file mode 100644 index 0000000..cc5940c --- /dev/null +++ b/Samples/BenchmarkTest00351.py @@ -0,0 +1,59 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/pathtraver-00/BenchmarkTest00351', methods=['GET']) + def BenchmarkTest00351_get(): + return BenchmarkTest00351_post() + + @app.route('/benchmark/pathtraver-00/BenchmarkTest00351', methods=['POST']) + def BenchmarkTest00351_post(): + RESPONSE = "" + + param = "" + for name in request.form.keys(): + if "BenchmarkTest00351" in request.form.getlist(name): + param = name + break + + bar = param + + import codecs + import helpers.utils + + try: + fileTarget = codecs.open(f'{helpers.utils.TESTFILES_DIR}/{bar}','r','utf-8') + + RESPONSE += ( + f"Access to file: \'{escape_for_html(fileTarget.name)}\' created." + ) + + RESPONSE += ( + " And file already exists." + ) + + except FileNotFoundError: + RESPONSE += ( + " But file doesn't exist yet." + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00366.py b/Samples/BenchmarkTest00366.py new file mode 100644 index 0000000..afa620e --- /dev/null +++ b/Samples/BenchmarkTest00366.py @@ -0,0 +1,50 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xss-00/BenchmarkTest00366', methods=['GET']) + def BenchmarkTest00366_get(): + return BenchmarkTest00366_post() + + @app.route('/benchmark/xss-00/BenchmarkTest00366', methods=['POST']) + def BenchmarkTest00366_post(): + RESPONSE = "" + + param = "" + for name in request.form.keys(): + if "BenchmarkTest00366" in request.form.getlist(name): + param = name + break + + map99262 = {} + map99262['keyA-99262'] = 'a-Value' + map99262['keyB-99262'] = param + map99262['keyC'] = 'another-Value' + bar = map99262['keyB-99262'] + + + otherarg = "static text" + RESPONSE += ( + 'bar is \'%s\' and otherarg is \'%s\'' % (bar, otherarg) + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00390.py b/Samples/BenchmarkTest00390.py new file mode 100644 index 0000000..0fc41a2 --- /dev/null +++ b/Samples/BenchmarkTest00390.py @@ -0,0 +1,62 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-01/BenchmarkTest00390', methods=['GET']) + def BenchmarkTest00390_get(): + return BenchmarkTest00390_post() + + @app.route('/benchmark/weakrand-01/BenchmarkTest00390', methods=['POST']) + def BenchmarkTest00390_post(): + RESPONSE = "" + + param = "" + for name in request.form.keys(): + if "BenchmarkTest00390" in request.form.getlist(name): + param = name + break + + num = 106 + + bar = "This_should_always_happen" if 7 * 18 + num > 200 else param + + import base64 + import secrets + from helpers.utils import mysession + + num = 'BenchmarkTest00390'[13:] + user = f'SafeToby{num}' + cookie = f'rememberMe{num}' + value = base64.b64encode(secrets.token_bytes(32)) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie:' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00394.py b/Samples/BenchmarkTest00394.py new file mode 100644 index 0000000..8c40cf3 --- /dev/null +++ b/Samples/BenchmarkTest00394.py @@ -0,0 +1,71 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-01/BenchmarkTest00394', methods=['GET']) + def BenchmarkTest00394_get(): + return BenchmarkTest00394_post() + + @app.route('/benchmark/weakrand-01/BenchmarkTest00394', methods=['POST']) + def BenchmarkTest00394_post(): + RESPONSE = "" + + param = "" + for name in request.form.keys(): + if "BenchmarkTest00394" in request.form.getlist(name): + param = name + break + + possible = "ABC" + guess = possible[0] + + match guess: + case 'A': + bar = param + case 'B': + bar = 'bob' + case 'C' | 'D': + bar = param + case _: + bar = 'bob\'s your uncle' + + import base64 + import secrets + from helpers.utils import mysession + + num = 'BenchmarkTest00394'[13:] + user = f'SafeTruman{num}' + cookie = f'rememberMe{num}' + value = secrets.token_urlsafe(32) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie:' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00408.py b/Samples/BenchmarkTest00408.py new file mode 100644 index 0000000..8c8e61f --- /dev/null +++ b/Samples/BenchmarkTest00408.py @@ -0,0 +1,61 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-01/BenchmarkTest00408', methods=['GET']) + def BenchmarkTest00408_get(): + return BenchmarkTest00408_post() + + @app.route('/benchmark/weakrand-01/BenchmarkTest00408', methods=['POST']) + def BenchmarkTest00408_post(): + RESPONSE = "" + + param = "" + for name in request.form.keys(): + if "BenchmarkTest00408" in request.form.getlist(name): + param = name + break + + num = 106 + + bar = "This_should_always_happen" if 7 * 18 + num > 200 else param + + import random + from helpers.utils import mysession + + num = 'BenchmarkTest00408'[13:] + user = f'SafeRandall{num}' + cookie = f'rememberMe{num}' + value = str(random.SystemRandom().random())[2:] + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie: ' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00412.py b/Samples/BenchmarkTest00412.py new file mode 100644 index 0000000..65ea1da --- /dev/null +++ b/Samples/BenchmarkTest00412.py @@ -0,0 +1,73 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/hash-00/BenchmarkTest00412', methods=['GET']) + def BenchmarkTest00412_get(): + return BenchmarkTest00412_post() + + @app.route('/benchmark/hash-00/BenchmarkTest00412', methods=['POST']) + def BenchmarkTest00412_post(): + RESPONSE = "" + + param = "" + for name in request.form.keys(): + if "BenchmarkTest00412" in request.form.getlist(name): + param = name + break + + bar = "" + if param: + lst = [] + lst.append('safe') + lst.append(param) + lst.append('moresafe') + lst.pop(0) + bar = lst[0] + + import hashlib, base64 + import io, helpers.utils + + input = '' + if isinstance(bar, str): + input = bar.encode('utf-8') + elif isinstance(bar, io.IOBase): + input = bar.read(1000) + + if len(input) == 0: + RESPONSE += ( + 'Cannot generate hash: Input was empty.' + ) + return RESPONSE + + hash = hashlib.md5() + hash.update(input) + + result = hash.digest() + f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + f.write(f'hash_value={base64.b64encode(result)}\n') + RESPONSE += ( + f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.' + ) + f.close() + + return RESPONSE + diff --git a/Samples/BenchmarkTest00430.py b/Samples/BenchmarkTest00430.py new file mode 100644 index 0000000..df3f048 --- /dev/null +++ b/Samples/BenchmarkTest00430.py @@ -0,0 +1,70 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/ldapi-00/BenchmarkTest00430', methods=['GET']) + def BenchmarkTest00430_get(): + return BenchmarkTest00430_post() + + @app.route('/benchmark/ldapi-00/BenchmarkTest00430', methods=['POST']) + def BenchmarkTest00430_post(): + RESPONSE = "" + + param = "" + for name in request.form.keys(): + if "BenchmarkTest00430" in request.form.getlist(name): + param = name + break + + string56477 = 'help' + string56477 += param + string56477 += 'snapes on a plane' + bar = string56477[4:-17] + + import helpers.ldap + import ldap3 + + base = 'ou=users,ou=system' + filter = f'(&(objectclass=person)(uid={bar}))' + try: + conn = helpers.ldap.get_connection() + conn.search(base, filter, attributes=ldap3.ALL_ATTRIBUTES) + found = False + for e in conn.entries: + RESPONSE += ( + f'LDAP query results:
' + f'Record found with name {e['uid']}
' + f'Address: {e['street']}
' + ) + found = True + conn.unbind() + + if not found: + RESPONSE += ( + f'LDAP query results: nothing found for query: {helpers.utils.escape_for_html(filter)}' + ) + except IOError: + RESPONSE += ( + "Error processing LDAP query." + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00433.py b/Samples/BenchmarkTest00433.py new file mode 100644 index 0000000..4b4b2a2 --- /dev/null +++ b/Samples/BenchmarkTest00433.py @@ -0,0 +1,57 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/deserialization-00/BenchmarkTest00433', methods=['GET']) + def BenchmarkTest00433_get(): + return BenchmarkTest00433_post() + + @app.route('/benchmark/deserialization-00/BenchmarkTest00433', methods=['POST']) + def BenchmarkTest00433_post(): + RESPONSE = "" + + param = "" + for name in request.form.keys(): + if "BenchmarkTest00433" in request.form.getlist(name): + param = name + break + + map74329 = {} + map74329['keyA-74329'] = 'a-Value' + map74329['keyB-74329'] = param + map74329['keyC'] = 'another-Value' + bar = map74329['keyB-74329'] + + import yaml + + try: + yobj = yaml.load(bar, Loader=yaml.Loader) + + RESPONSE += ( + yobj['text'] + ) + except: + RESPONSE += ( + "There was an error loading the configuration" + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00434.py b/Samples/BenchmarkTest00434.py new file mode 100644 index 0000000..04e8336 --- /dev/null +++ b/Samples/BenchmarkTest00434.py @@ -0,0 +1,56 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/deserialization-00/BenchmarkTest00434', methods=['GET']) + def BenchmarkTest00434_get(): + return BenchmarkTest00434_post() + + @app.route('/benchmark/deserialization-00/BenchmarkTest00434', methods=['POST']) + def BenchmarkTest00434_post(): + RESPONSE = "" + + param = "" + for name in request.form.keys(): + if "BenchmarkTest00434" in request.form.getlist(name): + param = name + break + + import helpers.ThingFactory + + thing = helpers.ThingFactory.createThing() + bar = thing.doSomething(param) + + import yaml + + try: + yobj = yaml.safe_load(bar) + + RESPONSE += ( + yobj['text'] + ) + except: + RESPONSE += ( + "There was an error loading the configuration" + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00436.py b/Samples/BenchmarkTest00436.py new file mode 100644 index 0000000..a57eb6c --- /dev/null +++ b/Samples/BenchmarkTest00436.py @@ -0,0 +1,50 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xss-00/BenchmarkTest00436', methods=['GET']) + def BenchmarkTest00436_get(): + return BenchmarkTest00436_post() + + @app.route('/benchmark/xss-00/BenchmarkTest00436', methods=['POST']) + def BenchmarkTest00436_post(): + RESPONSE = "" + + param = request.headers.get("Referer") + if not param: + param = "" + + bar = "alsosafe" + if param: + lst = [] + lst.append('safe') + lst.append(param) + lst.append('moresafe') + lst.pop(0) + bar = lst[1] + + + RESPONSE += ( + f'Parameter value: {bar}' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00439.py b/Samples/BenchmarkTest00439.py new file mode 100644 index 0000000..d3f0b2e --- /dev/null +++ b/Samples/BenchmarkTest00439.py @@ -0,0 +1,65 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/pathtraver-00/BenchmarkTest00439', methods=['GET']) + def BenchmarkTest00439_get(): + return BenchmarkTest00439_post() + + @app.route('/benchmark/pathtraver-00/BenchmarkTest00439', methods=['POST']) + def BenchmarkTest00439_post(): + RESPONSE = "" + + param = request.headers.get("BenchmarkTest00439") + if not param: + param = "" + + string92030 = 'help' + string92030 += param + string92030 += 'snapes on a plane' + bar = string92030[4:-17] + + import helpers.utils + + fileName = None + fd = None + + try: + fileName = f'{helpers.utils.TESTFILES_DIR}/{bar}' + fd = open(fileName, 'rb') + RESPONSE += ( + f'The beginning of file: \'{escape_for_html(fileName)}\' is:\n\n' + f'{escape_for_html(fd.read(1000).decode('utf-8'))}' + ) + except IOError as e: + RESPONSE += ( + f'Problem reading from file \'{{escape_for_html(fileName)}}\': ' + f'{escape_for_html(e.strerror)}' + ) + finally: + try: + if fd is not None: + fd.close() + except IOError: + pass # "// we tried..." + + return RESPONSE + diff --git a/Samples/BenchmarkTest00441.py b/Samples/BenchmarkTest00441.py new file mode 100644 index 0000000..d426d26 --- /dev/null +++ b/Samples/BenchmarkTest00441.py @@ -0,0 +1,60 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/pathtraver-00/BenchmarkTest00441', methods=['GET']) + def BenchmarkTest00441_get(): + return BenchmarkTest00441_post() + + @app.route('/benchmark/pathtraver-00/BenchmarkTest00441', methods=['POST']) + def BenchmarkTest00441_post(): + RESPONSE = "" + + param = request.headers.get("BenchmarkTest00441") + if not param: + param = "" + + num = 106 + + bar = "This_should_always_happen" if 7 * 18 + num > 200 else param + + import helpers.utils + + try: + fileName = f'{helpers.utils.TESTFILES_DIR}/{bar}' + fd = open(fileName, 'wb') + RESPONSE += ( + f'Now ready to write to file: {escape_for_html(fileName)}' + ) + except IOError as e: + RESPONSE += ( + f'Problem reading from file \'{escape_for_html(fileName)}\': ' + f'{escape_for_html(e.strerror)}' + ) + finally: + try: + if fd is not None: + fd.close() + except IOError: + pass # "// we tried..." + + return RESPONSE + diff --git a/Samples/BenchmarkTest00448.py b/Samples/BenchmarkTest00448.py new file mode 100644 index 0000000..adb2d2b --- /dev/null +++ b/Samples/BenchmarkTest00448.py @@ -0,0 +1,68 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/pathtraver-00/BenchmarkTest00448', methods=['GET']) + def BenchmarkTest00448_get(): + return BenchmarkTest00448_post() + + @app.route('/benchmark/pathtraver-00/BenchmarkTest00448', methods=['POST']) + def BenchmarkTest00448_post(): + RESPONSE = "" + + param = request.headers.get("BenchmarkTest00448") + if not param: + param = "" + + import configparser + + bar = 'safe!' + conf57737 = configparser.ConfigParser() + conf57737.add_section('section57737') + conf57737.set('section57737', 'keyA-57737', 'a_Value') + conf57737.set('section57737', 'keyB-57737', param) + bar = conf57737.get('section57737', 'keyA-57737') + + import pathlib + import helpers.utils + + try: + testfiles = pathlib.Path(helpers.utils.TESTFILES_DIR) + p = (testfiles / bar).resolve() + + if not str(p).startswith(str(testfiles)): + RESPONSE += ( + "Invalid Path." + ) + return RESPONSE + + RESPONSE += ( + f'The beginning of file: \'{escape_for_html(str(p))}\' is:\n\n' + f'{escape_for_html(p.read_text()[:1000])}' + ) + except OSError: + RESPONSE += ( + f'Problem reading from file \'{{escape_for_html(fileName)}}\': ' + f'{escape_for_html(e.strerror)}' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00450.py b/Samples/BenchmarkTest00450.py new file mode 100644 index 0000000..c66f05f --- /dev/null +++ b/Samples/BenchmarkTest00450.py @@ -0,0 +1,46 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xss-00/BenchmarkTest00450', methods=['GET']) + def BenchmarkTest00450_get(): + return BenchmarkTest00450_post() + + @app.route('/benchmark/xss-00/BenchmarkTest00450', methods=['POST']) + def BenchmarkTest00450_post(): + RESPONSE = "" + + param = request.headers.get("Referer") + if not param: + param = "" + + bar = "This should never happen" + if 'should' in bar: + bar = param + + + otherarg = "static text" + RESPONSE += ( + 'bar is \'{0}\' and otherarg is \'{1}\''.format(bar, otherarg) + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00452.py b/Samples/BenchmarkTest00452.py new file mode 100644 index 0000000..fd37113 --- /dev/null +++ b/Samples/BenchmarkTest00452.py @@ -0,0 +1,48 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xss-00/BenchmarkTest00452', methods=['GET']) + def BenchmarkTest00452_get(): + return BenchmarkTest00452_post() + + @app.route('/benchmark/xss-00/BenchmarkTest00452', methods=['POST']) + def BenchmarkTest00452_post(): + RESPONSE = "" + + param = request.headers.get("Referer") + if not param: + param = "" + + import html + + bar = html.escape(param) + + + dict = {} + dict['bar'] = bar + dict['otherarg'] = 'this is it' + RESPONSE += ( + 'bar is \'{0[bar]}\' and otherarg is \'{0[otherarg]}\''.format(dict) + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00458.py b/Samples/BenchmarkTest00458.py new file mode 100644 index 0000000..f55ebf1 --- /dev/null +++ b/Samples/BenchmarkTest00458.py @@ -0,0 +1,66 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xpathi-00/BenchmarkTest00458', methods=['GET']) + def BenchmarkTest00458_get(): + return BenchmarkTest00458_post() + + @app.route('/benchmark/xpathi-00/BenchmarkTest00458', methods=['POST']) + def BenchmarkTest00458_post(): + RESPONSE = "" + + param = request.headers.get("BenchmarkTest00458") + if not param: + param = "" + + num = 106 + + bar = "This_should_always_happen" if 7 * 18 + num > 200 else param + + import elementpath + import xml.etree.ElementTree as ET + import helpers.utils + + if '\'' in bar: + RESPONSE += ( + "Employee ID must not contain apostrophes" + ) + return RESPONSE + + try: + root = ET.parse(f'{helpers.utils.RES_DIR}/employees.xml') + query = f"/Employees/Employee[@emplid=\'{bar}\']" + nodes = elementpath.select(root, query) + node_strings = [] + for node in nodes: + node_strings.append(' '.join([e.text for e in node])) + + RESPONSE += ( + f'Your XPATH query results are:
[ {', '.join(node_strings)} ]' + ) + except: + RESPONSE += ( + f'Error parsing XPath Query: \'{escape_for_html(query)}\'' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00461.py b/Samples/BenchmarkTest00461.py new file mode 100644 index 0000000..7a1ea57 --- /dev/null +++ b/Samples/BenchmarkTest00461.py @@ -0,0 +1,71 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xxe-00/BenchmarkTest00461', methods=['GET']) + def BenchmarkTest00461_get(): + return BenchmarkTest00461_post() + + @app.route('/benchmark/xxe-00/BenchmarkTest00461', methods=['POST']) + def BenchmarkTest00461_post(): + RESPONSE = "" + + param = request.headers.get("BenchmarkTest00461") + if not param: + param = "" + + map63945 = {} + map63945['keyA-63945'] = 'a-Value' + map63945['keyB-63945'] = param + map63945['keyC'] = 'another-Value' + bar = "safe!" + bar = map63945['keyB-63945'] + bar = map63945['keyA-63945'] + + import xml.dom.minidom + import xml.sax.handler + + try: + parser = xml.sax.make_parser() + # all features are disabled by default + parser.setFeature(xml.sax.handler.feature_external_ges, True) + + doc = xml.dom.minidom.parseString(bar, parser) + + out = '' + processing = [doc.documentElement] + while processing: + e = processing.pop(0) + if e.nodeType == xml.dom.Node.TEXT_NODE: + out += e.data + else: + processing[:0] = e.childNodes + + RESPONSE += ( + f'Your XML doc results are:
{escape_for_html(out)}' + ) + except: + RESPONSE += ( + f'There was an error reading your XML doc:
{escape_for_html(bar)}' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00467.py b/Samples/BenchmarkTest00467.py new file mode 100644 index 0000000..5499879 --- /dev/null +++ b/Samples/BenchmarkTest00467.py @@ -0,0 +1,63 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xpathi-00/BenchmarkTest00467', methods=['GET']) + def BenchmarkTest00467_get(): + return BenchmarkTest00467_post() + + @app.route('/benchmark/xpathi-00/BenchmarkTest00467', methods=['POST']) + def BenchmarkTest00467_post(): + RESPONSE = "" + + param = request.headers.get("BenchmarkTest00467") + if not param: + param = "" + + num = 86 + + if 7 * 42 - num > 200: + bar = 'This_should_always_happen' + else: + bar = param + + import lxml.etree + import helpers.utils + + try: + fd = open(f'{helpers.utils.RES_DIR}/employees.xml', 'rb') + root = lxml.etree.parse(fd) + query = f'/Employees/Employee[@emplid=\'{bar.replace('\'', ''')}\']' + nodes = root.xpath(query) + node_strings = [] + for node in nodes: + node_strings.append(' '.join([e.text for e in node])) + + RESPONSE += ( + f'Your XPATH query results are:
[ {', '.join(node_strings)} ]' + ) + except: + RESPONSE += ( + f'Error parsing XPath Query: \'{escape_for_html(query)}\'' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00469.py b/Samples/BenchmarkTest00469.py new file mode 100644 index 0000000..e85d8ba --- /dev/null +++ b/Samples/BenchmarkTest00469.py @@ -0,0 +1,60 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xpathi-01/BenchmarkTest00469', methods=['GET']) + def BenchmarkTest00469_get(): + return BenchmarkTest00469_post() + + @app.route('/benchmark/xpathi-01/BenchmarkTest00469', methods=['POST']) + def BenchmarkTest00469_post(): + RESPONSE = "" + + param = request.headers.get("BenchmarkTest00469") + if not param: + param = "" + + import base64 + tmp = base64.b64encode(param.encode('utf-8')) + bar = base64.b64decode(tmp).decode('utf-8') + + import lxml.etree + import helpers.utils + + try: + fd = open(f'{helpers.utils.RES_DIR}/employees.xml', 'rb') + root = lxml.etree.parse(fd) + query = f'/Employees/Employee[@emplid=$name]' + nodes = root.xpath(query, name=bar) + node_strings = [] + for node in nodes: + node_strings.append(' '.join([e.text for e in node])) + + RESPONSE += ( + f'Your XPATH query results are:
[ {', '.join(node_strings)} ]' + ) + except: + RESPONSE += ( + f'Error parsing XPath Query: \'{escape_for_html(query)}\'' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00470.py b/Samples/BenchmarkTest00470.py new file mode 100644 index 0000000..c7b5db4 --- /dev/null +++ b/Samples/BenchmarkTest00470.py @@ -0,0 +1,69 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xpathi-01/BenchmarkTest00470', methods=['GET']) + def BenchmarkTest00470_get(): + return BenchmarkTest00470_post() + + @app.route('/benchmark/xpathi-01/BenchmarkTest00470', methods=['POST']) + def BenchmarkTest00470_post(): + RESPONSE = "" + + param = request.headers.get("BenchmarkTest00470") + if not param: + param = "" + + possible = "ABC" + guess = possible[1] + + match guess: + case 'A': + bar = param + case 'B': + bar = 'bob' + case 'C' | 'D': + bar = param + case _: + bar = 'bob\'s your uncle' + + import lxml.etree + import helpers.utils + + try: + fd = open(f'{helpers.utils.RES_DIR}/employees.xml', 'rb') + root = lxml.etree.parse(fd) + query = f'/Employees/Employee[@emplid=$name]' + nodes = root.xpath(query, name=bar) + node_strings = [] + for node in nodes: + node_strings.append(' '.join([e.text for e in node])) + + RESPONSE += ( + f'Your XPATH query results are:
[ {', '.join(node_strings)} ]' + ) + except: + RESPONSE += ( + f'Error parsing XPath Query: \'{escape_for_html(query)}\'' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00472.py b/Samples/BenchmarkTest00472.py new file mode 100644 index 0000000..13c3567 --- /dev/null +++ b/Samples/BenchmarkTest00472.py @@ -0,0 +1,67 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xpathi-01/BenchmarkTest00472', methods=['GET']) + def BenchmarkTest00472_get(): + return BenchmarkTest00472_post() + + @app.route('/benchmark/xpathi-01/BenchmarkTest00472', methods=['POST']) + def BenchmarkTest00472_post(): + RESPONSE = "" + + param = request.headers.get("BenchmarkTest00472") + if not param: + param = "" + + import helpers.ThingFactory + + thing = helpers.ThingFactory.createThing() + bar = thing.doSomething(param) + + import lxml.etree + import helpers.utils + import io + + try: + fd = open(f'{helpers.utils.RES_DIR}/employees.xml', 'rb') + root = lxml.etree.parse(fd) + strIO = io.StringIO() + strIO.write('/Employees/Employee[@emplid=\'') + strIO.write(bar) + strIO.write('\']') + query = strIO.getvalue() + + nodes = root.xpath(query) + node_strings = [] + for node in nodes: + node_strings.append(' '.join([e.text for e in node])) + + RESPONSE += ( + f'Your XPATH query results are:
[ {', '.join(node_strings)} ]' + ) + except: + RESPONSE += ( + f'Error parsing XPath Query: \'{escape_for_html(query)}\'' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00477.py b/Samples/BenchmarkTest00477.py new file mode 100644 index 0000000..6fd1aef --- /dev/null +++ b/Samples/BenchmarkTest00477.py @@ -0,0 +1,62 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-01/BenchmarkTest00477', methods=['GET']) + def BenchmarkTest00477_get(): + return BenchmarkTest00477_post() + + @app.route('/benchmark/weakrand-01/BenchmarkTest00477', methods=['POST']) + def BenchmarkTest00477_post(): + RESPONSE = "" + + param = request.headers.get("BenchmarkTest00477") + if not param: + param = "" + + num = 86 + + if 7 * 42 - num > 200: + bar = 'This_should_always_happen' + else: + bar = param + + import secrets + from helpers.utils import mysession + + num = 'BenchmarkTest00477'[13:] + user = f'SafeRicky{num}' + cookie = f'rememberMe{num}' + value = str(secrets.randbits(32)) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie:' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00488.py b/Samples/BenchmarkTest00488.py new file mode 100644 index 0000000..f00a305 --- /dev/null +++ b/Samples/BenchmarkTest00488.py @@ -0,0 +1,71 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/hash-00/BenchmarkTest00488', methods=['GET']) + def BenchmarkTest00488_get(): + return BenchmarkTest00488_post() + + @app.route('/benchmark/hash-00/BenchmarkTest00488', methods=['POST']) + def BenchmarkTest00488_post(): + RESPONSE = "" + + param = request.headers.get("BenchmarkTest00488") + if not param: + param = "" + + bar = "alsosafe" + if param: + lst = [] + lst.append('safe') + lst.append(param) + lst.append('moresafe') + lst.pop(0) + bar = lst[1] + + import hashlib, base64 + import io, helpers.utils + + input = '' + if isinstance(bar, str): + input = bar.encode('utf-8') + elif isinstance(bar, io.IOBase): + input = bar.read(1000) + + if len(input) == 0: + RESPONSE += ( + 'Cannot generate hash: Input was empty.' + ) + return RESPONSE + + hash = hashlib.new('sha512') + hash.update(input) + + result = hash.digest() + f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + f.write(f'hash_value={base64.b64encode(result)}\n') + RESPONSE += ( + f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.' + ) + f.close() + + return RESPONSE + diff --git a/Samples/BenchmarkTest00491.py b/Samples/BenchmarkTest00491.py new file mode 100644 index 0000000..493aa6d --- /dev/null +++ b/Samples/BenchmarkTest00491.py @@ -0,0 +1,70 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/hash-00/BenchmarkTest00491', methods=['GET']) + def BenchmarkTest00491_get(): + return BenchmarkTest00491_post() + + @app.route('/benchmark/hash-00/BenchmarkTest00491', methods=['POST']) + def BenchmarkTest00491_post(): + RESPONSE = "" + + param = request.headers.get("BenchmarkTest00491") + if not param: + param = "" + + map51084 = {} + map51084['keyA-51084'] = 'a-Value' + map51084['keyB-51084'] = param + map51084['keyC'] = 'another-Value' + bar = "safe!" + bar = map51084['keyB-51084'] + bar = map51084['keyA-51084'] + + import hashlib, base64 + import io, helpers.utils + + input = '' + if isinstance(bar, str): + input = bar.encode('utf-8') + elif isinstance(bar, io.IOBase): + input = bar.read(1000) + + if len(input) == 0: + RESPONSE += ( + 'Cannot generate hash: Input was empty.' + ) + return RESPONSE + + hash = hashlib.sha512() + hash.update(input) + + result = hash.digest() + f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + f.write(f'hash_value={base64.b64encode(result)}\n') + RESPONSE += ( + f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.' + ) + f.close() + + return RESPONSE + diff --git a/Samples/BenchmarkTest00494.py b/Samples/BenchmarkTest00494.py new file mode 100644 index 0000000..5c81454 --- /dev/null +++ b/Samples/BenchmarkTest00494.py @@ -0,0 +1,63 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/securecookie-00/BenchmarkTest00494', methods=['GET']) + def BenchmarkTest00494_get(): + return BenchmarkTest00494_post() + + @app.route('/benchmark/securecookie-00/BenchmarkTest00494', methods=['POST']) + def BenchmarkTest00494_post(): + RESPONSE = "" + + param = request.headers.get("BenchmarkTest00494") + if not param: + param = "" + + bar = '' + if param: + bar = param.split(' ')[0] + + from flask import make_response + import io + import helpers.utils + + input = '' + if isinstance(bar, str): + input = bar.encode('utf-8') + elif isinstance(bar, io.IOBase): + input = bar.read(1000) + + cookie = 'SomeCookie' + value = input.decode('utf-8') + + RESPONSE += ( + f'Created cookie: \'{cookie}\' with value \'{helpers.utils.escape_for_html(value)}\' and secure flag set to false.' + ) + + RESPONSE = make_response(RESPONSE) + RESPONSE.set_cookie(cookie, value, + path=request.path, + secure=False, + httponly=True) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00498.py b/Samples/BenchmarkTest00498.py new file mode 100644 index 0000000..bc17f19 --- /dev/null +++ b/Samples/BenchmarkTest00498.py @@ -0,0 +1,54 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/trustbound-00/BenchmarkTest00498', methods=['GET']) + def BenchmarkTest00498_get(): + return BenchmarkTest00498_post() + + @app.route('/benchmark/trustbound-00/BenchmarkTest00498', methods=['POST']) + def BenchmarkTest00498_post(): + RESPONSE = "" + + param = request.headers.get("BenchmarkTest00498") + if not param: + param = "" + + bar = "alsosafe" + if param: + lst = [] + lst.append('safe') + lst.append(param) + lst.append('moresafe') + lst.pop(0) + bar = lst[1] + + import flask + + flask.session['userid'] = bar + + RESPONSE += ( + f'Item: \'userid\' with value \'{escape_for_html(bar)}' + '\'saved in session.' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00502.py b/Samples/BenchmarkTest00502.py new file mode 100644 index 0000000..98d5856 --- /dev/null +++ b/Samples/BenchmarkTest00502.py @@ -0,0 +1,47 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/trustbound-00/BenchmarkTest00502', methods=['GET']) + def BenchmarkTest00502_get(): + return BenchmarkTest00502_post() + + @app.route('/benchmark/trustbound-00/BenchmarkTest00502', methods=['POST']) + def BenchmarkTest00502_post(): + RESPONSE = "" + + param = request.headers.get("BenchmarkTest00502") + if not param: + param = "" + + bar = param + '_SafeStuff' + + import flask + + flask.session[bar] = '12345' + + RESPONSE += ( + f'Item: \'{escape_for_html(bar)}' + '\' with value: 12345 saved in session.' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00506.py b/Samples/BenchmarkTest00506.py new file mode 100644 index 0000000..47664f9 --- /dev/null +++ b/Samples/BenchmarkTest00506.py @@ -0,0 +1,72 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/ldapi-00/BenchmarkTest00506', methods=['GET']) + def BenchmarkTest00506_get(): + return BenchmarkTest00506_post() + + @app.route('/benchmark/ldapi-00/BenchmarkTest00506', methods=['POST']) + def BenchmarkTest00506_post(): + RESPONSE = "" + + param = request.headers.get("BenchmarkTest00506") + if not param: + param = "" + + import configparser + + bar = 'safe!' + conf42361 = configparser.ConfigParser() + conf42361.add_section('section42361') + conf42361.set('section42361', 'keyA-42361', 'a-Value') + conf42361.set('section42361', 'keyB-42361', param) + bar = conf42361.get('section42361', 'keyB-42361') + + import helpers.ldap + import ldap3 + + base = 'ou=users,ou=system' + filter = f'(&(objectclass=person)(uid={bar}))' + try: + conn = helpers.ldap.get_connection() + conn.search(base, filter, attributes=ldap3.ALL_ATTRIBUTES) + found = False + for e in conn.entries: + RESPONSE += ( + f'LDAP query results:
' + f'Record found with name {e['uid']}
' + f'Address: {e['street']}
' + ) + found = True + conn.unbind() + + if not found: + RESPONSE += ( + f'LDAP query results: nothing found for query: {helpers.utils.escape_for_html(filter)}' + ) + except IOError: + RESPONSE += ( + "Error processing LDAP query." + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00508.py b/Samples/BenchmarkTest00508.py new file mode 100644 index 0000000..7a83fc8 --- /dev/null +++ b/Samples/BenchmarkTest00508.py @@ -0,0 +1,67 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/deserialization-00/BenchmarkTest00508', methods=['GET']) + def BenchmarkTest00508_get(): + return BenchmarkTest00508_post() + + @app.route('/benchmark/deserialization-00/BenchmarkTest00508', methods=['POST']) + def BenchmarkTest00508_post(): + RESPONSE = "" + + param = request.headers.get("BenchmarkTest00508") + if not param: + param = "" + + possible = "ABC" + guess = possible[1] + + match guess: + case 'A': + bar = param + case 'B': + bar = 'bob' + case 'C' | 'D': + bar = param + case _: + bar = 'bob\'s your uncle' + + import pickle + import base64 + import helpers.utils + + helpers.utils.sharedstr = "no pickles to be seen here" + + try: + unpickled = pickle.loads(base64.urlsafe_b64decode(bar)) + except: + RESPONSE += ( + 'Unpickling failed!' + ) + return RESPONSE + + RESPONSE += ( + f'shared string is {helpers.utils.sharedstr}' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00515.py b/Samples/BenchmarkTest00515.py new file mode 100644 index 0000000..3d6d9d2 --- /dev/null +++ b/Samples/BenchmarkTest00515.py @@ -0,0 +1,47 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xss-00/BenchmarkTest00515', methods=['GET']) + def BenchmarkTest00515_get(): + return BenchmarkTest00515_post() + + @app.route('/benchmark/xss-00/BenchmarkTest00515', methods=['POST']) + def BenchmarkTest00515_post(): + RESPONSE = "" + + param = "" + headers = request.headers.getlist("Referer") + + if headers: + param = headers[0] + + num = 106 + + bar = "This should never happen" if (7*42) - num > 200 else param + + + RESPONSE += ( + f'Parameter value: {bar}' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00539.py b/Samples/BenchmarkTest00539.py new file mode 100644 index 0000000..e73206e --- /dev/null +++ b/Samples/BenchmarkTest00539.py @@ -0,0 +1,69 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xxe-00/BenchmarkTest00539', methods=['GET']) + def BenchmarkTest00539_get(): + return BenchmarkTest00539_post() + + @app.route('/benchmark/xxe-00/BenchmarkTest00539', methods=['POST']) + def BenchmarkTest00539_post(): + RESPONSE = "" + + param = "" + headers = request.headers.getlist("BenchmarkTest00539") + + if headers: + param = headers[0] + + string25731 = 'help' + string25731 += param + string25731 += 'snapes on a plane' + bar = string25731[4:-17] + + import xml.dom.minidom + import xml.sax.handler + + try: + parser = xml.sax.make_parser() + # all features are disabled by default + + doc = xml.dom.minidom.parseString(bar, parser) + + out = '' + processing = [doc.documentElement] + while processing: + e = processing.pop(0) + if e.nodeType == xml.dom.Node.TEXT_NODE: + out += e.data + else: + processing[:0] = e.childNodes + + RESPONSE += ( + f'Your XML doc results are:
{escape_for_html(out)}' + ) + except: + RESPONSE += ( + f'There was an error reading your XML doc:
{escape_for_html(bar)}' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00540.py b/Samples/BenchmarkTest00540.py new file mode 100644 index 0000000..9defcfc --- /dev/null +++ b/Samples/BenchmarkTest00540.py @@ -0,0 +1,78 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xxe-00/BenchmarkTest00540', methods=['GET']) + def BenchmarkTest00540_get(): + return BenchmarkTest00540_post() + + @app.route('/benchmark/xxe-00/BenchmarkTest00540', methods=['POST']) + def BenchmarkTest00540_post(): + RESPONSE = "" + + param = "" + headers = request.headers.getlist("BenchmarkTest00540") + + if headers: + param = headers[0] + + possible = "ABC" + guess = possible[1] + + match guess: + case 'A': + bar = param + case 'B': + bar = 'bob' + case 'C' | 'D': + bar = param + case _: + bar = 'bob\'s your uncle' + + import xml.dom.minidom + import xml.sax.handler + + try: + parser = xml.sax.make_parser() + # all features are disabled by default + parser.setFeature(xml.sax.handler.feature_external_ges, True) + + doc = xml.dom.minidom.parseString(bar, parser) + + out = '' + processing = [doc.documentElement] + while processing: + e = processing.pop(0) + if e.nodeType == xml.dom.Node.TEXT_NODE: + out += e.data + else: + processing[:0] = e.childNodes + + RESPONSE += ( + f'Your XML doc results are:
{escape_for_html(out)}' + ) + except: + RESPONSE += ( + f'There was an error reading your XML doc:
{escape_for_html(bar)}' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00542.py b/Samples/BenchmarkTest00542.py new file mode 100644 index 0000000..ecf9987 --- /dev/null +++ b/Samples/BenchmarkTest00542.py @@ -0,0 +1,66 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xpathi-01/BenchmarkTest00542', methods=['GET']) + def BenchmarkTest00542_get(): + return BenchmarkTest00542_post() + + @app.route('/benchmark/xpathi-01/BenchmarkTest00542', methods=['POST']) + def BenchmarkTest00542_post(): + RESPONSE = "" + + param = "" + headers = request.headers.getlist("BenchmarkTest00542") + + if headers: + param = headers[0] + + map29056 = {} + map29056['keyA-29056'] = 'a-Value' + map29056['keyB-29056'] = param + map29056['keyC'] = 'another-Value' + bar = "safe!" + bar = map29056['keyB-29056'] + bar = map29056['keyA-29056'] + + import lxml.etree + import helpers.utils + + try: + fd = open(f'{helpers.utils.RES_DIR}/employees.xml', 'rb') + root = lxml.etree.parse(fd) + query = f'/Employees/Employee[@emplid=\'{bar}\']' + nodes = root.xpath(query) + node_strings = [] + for node in nodes: + node_strings.append(' '.join([e.text for e in node])) + + RESPONSE += ( + f'Your XPATH query results are:
[ {', '.join(node_strings)} ]' + ) + except: + RESPONSE += ( + f'Error parsing XPath Query: \'{escape_for_html(query)}\'' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00543.py b/Samples/BenchmarkTest00543.py new file mode 100644 index 0000000..e23ce1c --- /dev/null +++ b/Samples/BenchmarkTest00543.py @@ -0,0 +1,63 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xpathi-01/BenchmarkTest00543', methods=['GET']) + def BenchmarkTest00543_get(): + return BenchmarkTest00543_post() + + @app.route('/benchmark/xpathi-01/BenchmarkTest00543', methods=['POST']) + def BenchmarkTest00543_post(): + RESPONSE = "" + + param = "" + headers = request.headers.getlist("BenchmarkTest00543") + + if headers: + param = headers[0] + + bar = "This should never happen" + if 'should' in bar: + bar = param + + import lxml.etree + import helpers.utils + + try: + fd = open(f'{helpers.utils.RES_DIR}/employees.xml', 'rb') + root = lxml.etree.parse(fd) + query = "".join(['/Employees/Employee[@emplid=\'', bar, '\']']) + + nodes = root.xpath(query) + node_strings = [] + for node in nodes: + node_strings.append(' '.join([e.text for e in node])) + + RESPONSE += ( + f'Your XPATH query results are:
[ {', '.join(node_strings)} ]' + ) + except: + RESPONSE += ( + f'Error parsing XPath Query: \'{escape_for_html(query)}\'' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00547.py b/Samples/BenchmarkTest00547.py new file mode 100644 index 0000000..465a083 --- /dev/null +++ b/Samples/BenchmarkTest00547.py @@ -0,0 +1,68 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xpathi-01/BenchmarkTest00547', methods=['GET']) + def BenchmarkTest00547_get(): + return BenchmarkTest00547_post() + + @app.route('/benchmark/xpathi-01/BenchmarkTest00547', methods=['POST']) + def BenchmarkTest00547_post(): + RESPONSE = "" + + param = "" + headers = request.headers.getlist("BenchmarkTest00547") + + if headers: + param = headers[0] + + bar = "alsosafe" + if param: + lst = [] + lst.append('safe') + lst.append(param) + lst.append('moresafe') + lst.pop(0) + bar = lst[1] + + import lxml.etree + import helpers.utils + + try: + fd = open(f'{helpers.utils.RES_DIR}/employees.xml', 'rb') + root = lxml.etree.parse(fd) + query = '/Employees/Employee[@emplid=\'' + bar + '\']' + + nodes = root.xpath(query) + node_strings = [] + for node in nodes: + node_strings.append(' '.join([e.text for e in node])) + + RESPONSE += ( + f'Your XPATH query results are:
[ {', '.join(node_strings)} ]' + ) + except: + RESPONSE += ( + f'Error parsing XPath Query: \'{escape_for_html(query)}\'' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00549.py b/Samples/BenchmarkTest00549.py new file mode 100644 index 0000000..5319e7e --- /dev/null +++ b/Samples/BenchmarkTest00549.py @@ -0,0 +1,66 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xpathi-01/BenchmarkTest00549', methods=['GET']) + def BenchmarkTest00549_get(): + return BenchmarkTest00549_post() + + @app.route('/benchmark/xpathi-01/BenchmarkTest00549', methods=['POST']) + def BenchmarkTest00549_post(): + RESPONSE = "" + + param = "" + headers = request.headers.getlist("BenchmarkTest00549") + + if headers: + param = headers[0] + + bar = param + + import lxml.etree + import helpers.utils + + try: + if '\'' in bar: + RESPONSE += ( + "Employee ID must not contain apostrophes" + ) + return RESPONSE + + fd = open(f'{helpers.utils.RES_DIR}/employees.xml', 'rb') + root = lxml.etree.parse(fd) + query = f'/Employees/Employee[@emplid=\'{bar}\']' + nodes = root.xpath(query) + node_strings = [] + for node in nodes: + node_strings.append(' '.join([e.text for e in node])) + + RESPONSE += ( + f'Your XPATH query results are:
[ {', '.join(node_strings)} ]' + ) + except: + RESPONSE += ( + f'Error parsing XPath Query: \'{escape_for_html(query)}\'' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00553.py b/Samples/BenchmarkTest00553.py new file mode 100644 index 0000000..a96083d --- /dev/null +++ b/Samples/BenchmarkTest00553.py @@ -0,0 +1,64 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xpathi-01/BenchmarkTest00553', methods=['GET']) + def BenchmarkTest00553_get(): + return BenchmarkTest00553_post() + + @app.route('/benchmark/xpathi-01/BenchmarkTest00553', methods=['POST']) + def BenchmarkTest00553_post(): + RESPONSE = "" + + param = "" + headers = request.headers.getlist("BenchmarkTest00553") + + if headers: + param = headers[0] + + map30881 = {} + map30881['keyA-30881'] = 'a-Value' + map30881['keyB-30881'] = param + map30881['keyC'] = 'another-Value' + bar = map30881['keyB-30881'] + + import lxml.etree + import helpers.utils + + try: + fd = open(f'{helpers.utils.RES_DIR}/employees.xml', 'rb') + root = lxml.etree.parse(fd) + query = f'/Employees/Employee[@emplid=$name]' + nodes = root.xpath(query, name=bar) + node_strings = [] + for node in nodes: + node_strings.append(' '.join([e.text for e in node])) + + RESPONSE += ( + f'Your XPATH query results are:
[ {', '.join(node_strings)} ]' + ) + except: + RESPONSE += ( + f'Error parsing XPath Query: \'{escape_for_html(query)}\'' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00564.py b/Samples/BenchmarkTest00564.py new file mode 100644 index 0000000..946ecee --- /dev/null +++ b/Samples/BenchmarkTest00564.py @@ -0,0 +1,59 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-01/BenchmarkTest00564', methods=['GET']) + def BenchmarkTest00564_get(): + return BenchmarkTest00564_post() + + @app.route('/benchmark/weakrand-01/BenchmarkTest00564', methods=['POST']) + def BenchmarkTest00564_post(): + RESPONSE = "" + + param = "" + headers = request.headers.getlist("BenchmarkTest00564") + + if headers: + param = headers[0] + + bar = param + '_SafeStuff' + + import random + from helpers.utils import mysession + + num = 'BenchmarkTest00564'[13:] + user = f'Randall{num}' + cookie = f'rememberMe{num}' + value = str(random.random())[2:] + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie: ' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00570.py b/Samples/BenchmarkTest00570.py new file mode 100644 index 0000000..0459274 --- /dev/null +++ b/Samples/BenchmarkTest00570.py @@ -0,0 +1,60 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-01/BenchmarkTest00570', methods=['GET']) + def BenchmarkTest00570_get(): + return BenchmarkTest00570_post() + + @app.route('/benchmark/weakrand-01/BenchmarkTest00570', methods=['POST']) + def BenchmarkTest00570_post(): + RESPONSE = "" + + param = "" + headers = request.headers.getlist("BenchmarkTest00570") + + if headers: + param = headers[0] + + bar = param + + import base64 + import secrets + from helpers.utils import mysession + + num = 'BenchmarkTest00570'[13:] + user = f'SafeTruman{num}' + cookie = f'rememberMe{num}' + value = secrets.token_urlsafe(32) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie:' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00571.py b/Samples/BenchmarkTest00571.py new file mode 100644 index 0000000..b7244f1 --- /dev/null +++ b/Samples/BenchmarkTest00571.py @@ -0,0 +1,61 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-01/BenchmarkTest00571', methods=['GET']) + def BenchmarkTest00571_get(): + return BenchmarkTest00571_post() + + @app.route('/benchmark/weakrand-01/BenchmarkTest00571', methods=['POST']) + def BenchmarkTest00571_post(): + RESPONSE = "" + + param = "" + headers = request.headers.getlist("BenchmarkTest00571") + + if headers: + param = headers[0] + + import helpers.utils + bar = helpers.utils.escape_for_html(param) + + import random + import base64 + from helpers.utils import mysession + + num = 'BenchmarkTest00571'[13:] + user = f'SafeBarbara{num}' + cookie = f'rememberMe{num}' + value = str(base64.b64encode(random.SystemRandom().randbytes(32))) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie: ' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00593.py b/Samples/BenchmarkTest00593.py new file mode 100644 index 0000000..e95d294 --- /dev/null +++ b/Samples/BenchmarkTest00593.py @@ -0,0 +1,66 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/securecookie-00/BenchmarkTest00593', methods=['GET']) + def BenchmarkTest00593_get(): + return BenchmarkTest00593_post() + + @app.route('/benchmark/securecookie-00/BenchmarkTest00593', methods=['POST']) + def BenchmarkTest00593_post(): + RESPONSE = "" + + param = "" + headers = request.headers.getlist("BenchmarkTest00593") + + if headers: + param = headers[0] + + import helpers.ThingFactory + + thing = helpers.ThingFactory.createThing() + bar = thing.doSomething(param) + + from flask import make_response + import io + import helpers.utils + + input = '' + if isinstance(bar, str): + input = bar.encode('utf-8') + elif isinstance(bar, io.IOBase): + input = bar.read(1000) + + cookie = 'SomeCookie' + value = input.decode('utf-8') + + RESPONSE += ( + f'Created cookie: \'{cookie}\' with value \'{helpers.utils.escape_for_html(value)}\' and secure flag set to false.' + ) + + RESPONSE = make_response(RESPONSE) + RESPONSE.set_cookie(cookie, value, + path=request.path, + secure=False, + httponly=True) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00601.py b/Samples/BenchmarkTest00601.py new file mode 100644 index 0000000..e2c41d0 --- /dev/null +++ b/Samples/BenchmarkTest00601.py @@ -0,0 +1,52 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/codeinj-00/BenchmarkTest00601', methods=['GET']) + def BenchmarkTest00601_get(): + return BenchmarkTest00601_post() + + @app.route('/benchmark/codeinj-00/BenchmarkTest00601', methods=['POST']) + def BenchmarkTest00601_post(): + RESPONSE = "" + + param = "" + headers = request.headers.getlist("BenchmarkTest00601") + + if headers: + param = headers[0] + + import helpers.ThingFactory + + thing = helpers.ThingFactory.createThing() + bar = thing.doSomething(param) + + try: + RESPONSE += ( + eval(bar) + ) + except: + RESPONSE += ( + f'Error evaluating expression \'{escape_for_html(bar)}\'' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00602.py b/Samples/BenchmarkTest00602.py new file mode 100644 index 0000000..1e2fd19 --- /dev/null +++ b/Samples/BenchmarkTest00602.py @@ -0,0 +1,54 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/codeinj-00/BenchmarkTest00602', methods=['GET']) + def BenchmarkTest00602_get(): + return BenchmarkTest00602_post() + + @app.route('/benchmark/codeinj-00/BenchmarkTest00602', methods=['POST']) + def BenchmarkTest00602_post(): + RESPONSE = "" + + param = "" + headers = request.headers.getlist("BenchmarkTest00602") + + if headers: + param = headers[0] + + import configparser + + bar = 'safe!' + conf75466 = configparser.ConfigParser() + conf75466.add_section('section75466') + conf75466.set('section75466', 'keyA-75466', 'a_Value') + conf75466.set('section75466', 'keyB-75466', param) + bar = conf75466.get('section75466', 'keyA-75466') + + try: + exec(bar) + except: + RESPONSE += ( + f'Error executing statement \'{escape_for_html(bar)}\'' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00612.py b/Samples/BenchmarkTest00612.py new file mode 100644 index 0000000..8f8d4cd --- /dev/null +++ b/Samples/BenchmarkTest00612.py @@ -0,0 +1,67 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/pathtraver-01/BenchmarkTest00612', methods=['GET']) + def BenchmarkTest00612_get(): + return BenchmarkTest00612_post() + + @app.route('/benchmark/pathtraver-01/BenchmarkTest00612', methods=['POST']) + def BenchmarkTest00612_post(): + RESPONSE = "" + + import helpers.utils + param = "" + + for name in request.headers.keys(): + if name.lower() in helpers.utils.commonHeaderNames: + continue + + if request.headers.get_all(name): + param = name + break + + import helpers.ThingFactory + + thing = helpers.ThingFactory.createThing() + bar = thing.doSomething(param) + + import codecs + import helpers.utils + + try: + fileTarget = codecs.open(f'{helpers.utils.TESTFILES_DIR}/{bar}','r','utf-8') + + RESPONSE += ( + f"Access to file: \'{escape_for_html(fileTarget.name)}\' created." + ) + + RESPONSE += ( + " And file already exists." + ) + + except FileNotFoundError: + RESPONSE += ( + " But file doesn't exist yet." + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00630.py b/Samples/BenchmarkTest00630.py new file mode 100644 index 0000000..8ef9ab5 --- /dev/null +++ b/Samples/BenchmarkTest00630.py @@ -0,0 +1,69 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-02/BenchmarkTest00630', methods=['GET']) + def BenchmarkTest00630_get(): + return BenchmarkTest00630_post() + + @app.route('/benchmark/weakrand-02/BenchmarkTest00630', methods=['POST']) + def BenchmarkTest00630_post(): + RESPONSE = "" + + import helpers.utils + param = "" + + for name in request.headers.keys(): + if name.lower() in helpers.utils.commonHeaderNames: + continue + + if request.headers.get_all(name): + param = name + break + + num = 86 + + if 7 * 42 - num > 200: + bar = 'This_should_always_happen' + else: + bar = param + + import secrets + from helpers.utils import mysession + + num = 'BenchmarkTest00630'[13:] + user = f'SafeRobbie{num}' + cookie = f'rememberMe{num}' + value = str(secrets.randbelow(2**32)) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie:' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00639.py b/Samples/BenchmarkTest00639.py new file mode 100644 index 0000000..d56798b --- /dev/null +++ b/Samples/BenchmarkTest00639.py @@ -0,0 +1,65 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-02/BenchmarkTest00639', methods=['GET']) + def BenchmarkTest00639_get(): + return BenchmarkTest00639_post() + + @app.route('/benchmark/weakrand-02/BenchmarkTest00639', methods=['POST']) + def BenchmarkTest00639_post(): + RESPONSE = "" + + import helpers.utils + param = "" + + for name in request.headers.keys(): + if name.lower() in helpers.utils.commonHeaderNames: + continue + + if request.headers.get_all(name): + param = name + break + + superstring = f'27036{param}abcd' + bar = superstring[len('27036'):len(superstring)-5] + + import random + from helpers.utils import mysession + + num = 'BenchmarkTest00639'[13:] + user = f'SafeIsaac{num}' + cookie = f'rememberMe{num}' + value = str(random.SystemRandom().randint(0, 2**32)) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie: ' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00645.py b/Samples/BenchmarkTest00645.py new file mode 100644 index 0000000..84e2a0c --- /dev/null +++ b/Samples/BenchmarkTest00645.py @@ -0,0 +1,74 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/hash-00/BenchmarkTest00645', methods=['GET']) + def BenchmarkTest00645_get(): + return BenchmarkTest00645_post() + + @app.route('/benchmark/hash-00/BenchmarkTest00645', methods=['POST']) + def BenchmarkTest00645_post(): + RESPONSE = "" + + import helpers.utils + param = "" + + for name in request.headers.keys(): + if name.lower() in helpers.utils.commonHeaderNames: + continue + + if request.headers.get_all(name): + param = name + break + + import helpers.ThingFactory + + thing = helpers.ThingFactory.createThing() + bar = thing.doSomething(param) + + import hashlib, base64 + import io, helpers.utils + + input = '' + if isinstance(bar, str): + input = bar.encode('utf-8') + elif isinstance(bar, io.IOBase): + input = bar.read(1000) + + if len(input) == 0: + RESPONSE += ( + 'Cannot generate hash: Input was empty.' + ) + return RESPONSE + + hash = hashlib.new('sha512') + hash.update(input) + + result = hash.digest() + f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + f.write(f'hash_value={base64.b64encode(result)}\n') + RESPONSE += ( + f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.' + ) + f.close() + + return RESPONSE + diff --git a/Samples/BenchmarkTest00647.py b/Samples/BenchmarkTest00647.py new file mode 100644 index 0000000..915c0a0 --- /dev/null +++ b/Samples/BenchmarkTest00647.py @@ -0,0 +1,73 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/hash-00/BenchmarkTest00647', methods=['GET']) + def BenchmarkTest00647_get(): + return BenchmarkTest00647_post() + + @app.route('/benchmark/hash-00/BenchmarkTest00647', methods=['POST']) + def BenchmarkTest00647_post(): + RESPONSE = "" + + import helpers.utils + param = "" + + for name in request.headers.keys(): + if name.lower() in helpers.utils.commonHeaderNames: + continue + + if request.headers.get_all(name): + param = name + break + + bar = "This should never happen" + if 'should' in bar: + bar = param + + import hashlib, base64 + import io, helpers.utils + + input = '' + if isinstance(bar, str): + input = bar.encode('utf-8') + elif isinstance(bar, io.IOBase): + input = bar.read(1000) + + if len(input) == 0: + RESPONSE += ( + 'Cannot generate hash: Input was empty.' + ) + return RESPONSE + + hash = hashlib.md5() + hash.update(input) + + result = hash.digest() + f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + f.write(f'hash_value={base64.b64encode(result)}\n') + RESPONSE += ( + f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.' + ) + f.close() + + return RESPONSE + diff --git a/Samples/BenchmarkTest00664.py b/Samples/BenchmarkTest00664.py new file mode 100644 index 0000000..a2e6130 --- /dev/null +++ b/Samples/BenchmarkTest00664.py @@ -0,0 +1,68 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/pathtraver-01/BenchmarkTest00664', methods=['GET']) + def BenchmarkTest00664_get(): + return BenchmarkTest00664_post() + + @app.route('/benchmark/pathtraver-01/BenchmarkTest00664', methods=['POST']) + def BenchmarkTest00664_post(): + RESPONSE = "" + + param = request.args.get("BenchmarkTest00664") + if not param: + param = "" + + import configparser + + bar = 'safe!' + conf55264 = configparser.ConfigParser() + conf55264.add_section('section55264') + conf55264.set('section55264', 'keyA-55264', 'a_Value') + conf55264.set('section55264', 'keyB-55264', param) + bar = conf55264.get('section55264', 'keyA-55264') + + import pathlib + import helpers.utils + + try: + testfiles = pathlib.Path(helpers.utils.TESTFILES_DIR) + p = (testfiles / bar).resolve() + + if not str(p).startswith(str(testfiles)): + RESPONSE += ( + "Invalid Path." + ) + return RESPONSE + + RESPONSE += ( + f'The beginning of file: \'{escape_for_html(str(p))}\' is:\n\n' + f'{escape_for_html(p.read_text()[:1000])}' + ) + except OSError: + RESPONSE += ( + f'Problem reading from file \'{{escape_for_html(fileName)}}\': ' + f'{escape_for_html(e.strerror)}' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00665.py b/Samples/BenchmarkTest00665.py new file mode 100644 index 0000000..72ddc31 --- /dev/null +++ b/Samples/BenchmarkTest00665.py @@ -0,0 +1,60 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/pathtraver-01/BenchmarkTest00665', methods=['GET']) + def BenchmarkTest00665_get(): + return BenchmarkTest00665_post() + + @app.route('/benchmark/pathtraver-01/BenchmarkTest00665', methods=['POST']) + def BenchmarkTest00665_post(): + RESPONSE = "" + + param = request.args.get("BenchmarkTest00665") + if not param: + param = "" + + map59129 = {} + map59129['keyA-59129'] = 'a-Value' + map59129['keyB-59129'] = param + map59129['keyC'] = 'another-Value' + bar = map59129['keyB-59129'] + + import helpers.utils + + fileName = None + fd = None + + try: + fileName = f'{helpers.utils.TESTFILES_DIR}/{bar}' + with open(fileName, 'rb') as fd: + RESPONSE += ( + f'The beginning of file: \'{escape_for_html(fileName)}\' is:\n\n' + f'{escape_for_html(fd.read(1000).decode('utf-8'))}' + ) + except IOError as e: + RESPONSE += ( + f'Problem reading from file \'{{escape_for_html(fileName)}}\': ' + f'{escape_for_html(e.strerror)}' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00677.py b/Samples/BenchmarkTest00677.py new file mode 100644 index 0000000..326bf80 --- /dev/null +++ b/Samples/BenchmarkTest00677.py @@ -0,0 +1,61 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xpathi-01/BenchmarkTest00677', methods=['GET']) + def BenchmarkTest00677_get(): + return BenchmarkTest00677_post() + + @app.route('/benchmark/xpathi-01/BenchmarkTest00677', methods=['POST']) + def BenchmarkTest00677_post(): + RESPONSE = "" + + param = request.args.get("BenchmarkTest00677") + if not param: + param = "" + + import helpers.ThingFactory + + thing = helpers.ThingFactory.createThing() + bar = thing.doSomething(param) + + import elementpath + import xml.etree.ElementTree as ET + import helpers.utils + + try: + root = ET.parse(f'{helpers.utils.RES_DIR}/employees.xml') + nodes = elementpath.select(root, f"/Employees/Employee[@emplid=\'{bar.replace('\'', ''')}\']") + node_strings = [] + for node in nodes: + node_strings.append(' '.join([e.text for e in node])) + + RESPONSE += ( + f'Your XPATH query results are:
[ {', '.join(node_strings)} ]' + ) + except: + RESPONSE += ( + f'Error parsing XPath Query: \'{escape_for_html(query)}\'' + ) + + + return RESPONSE + diff --git a/Samples/BenchmarkTest00690.py b/Samples/BenchmarkTest00690.py new file mode 100644 index 0000000..5aad849 --- /dev/null +++ b/Samples/BenchmarkTest00690.py @@ -0,0 +1,64 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-02/BenchmarkTest00690', methods=['GET']) + def BenchmarkTest00690_get(): + return BenchmarkTest00690_post() + + @app.route('/benchmark/weakrand-02/BenchmarkTest00690', methods=['POST']) + def BenchmarkTest00690_post(): + RESPONSE = "" + + param = request.args.get("BenchmarkTest00690") + if not param: + param = "" + + bar = "" + if param: + lst = [] + lst.append('safe') + lst.append(param) + lst.append('moresafe') + lst.pop(0) + bar = lst[0] + + import random + from helpers.utils import mysession + + num = 'BenchmarkTest00690'[13:] + user = f'Isaac{num}' + cookie = f'rememberMe{num}' + value = str(random.randint(0, 2**32)) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie: ' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00693.py b/Samples/BenchmarkTest00693.py new file mode 100644 index 0000000..a011033 --- /dev/null +++ b/Samples/BenchmarkTest00693.py @@ -0,0 +1,59 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-02/BenchmarkTest00693', methods=['GET']) + def BenchmarkTest00693_get(): + return BenchmarkTest00693_post() + + @app.route('/benchmark/weakrand-02/BenchmarkTest00693', methods=['POST']) + def BenchmarkTest00693_post(): + RESPONSE = "" + + param = request.args.get("BenchmarkTest00693") + if not param: + param = "" + + import base64 + tmp = base64.b64encode(param.encode('utf-8')) + bar = base64.b64decode(tmp).decode('utf-8') + + import secrets + from helpers.utils import mysession + + num = 'BenchmarkTest00693'[13:] + user = f'SafeRicky{num}' + cookie = f'rememberMe{num}' + value = str(secrets.randbits(32)) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie:' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00695.py b/Samples/BenchmarkTest00695.py new file mode 100644 index 0000000..5739f5c --- /dev/null +++ b/Samples/BenchmarkTest00695.py @@ -0,0 +1,58 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-02/BenchmarkTest00695', methods=['GET']) + def BenchmarkTest00695_get(): + return BenchmarkTest00695_post() + + @app.route('/benchmark/weakrand-02/BenchmarkTest00695', methods=['POST']) + def BenchmarkTest00695_post(): + RESPONSE = "" + + param = request.args.get("BenchmarkTest00695") + if not param: + param = "" + + bar = param + + import base64 + import secrets + from helpers.utils import mysession + + num = 'BenchmarkTest00695'[13:] + user = f'SafeTheo{num}' + cookie = f'rememberMe{num}' + value = secrets.token_hex(32) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie:' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00697.py b/Samples/BenchmarkTest00697.py new file mode 100644 index 0000000..df8a031 --- /dev/null +++ b/Samples/BenchmarkTest00697.py @@ -0,0 +1,60 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-02/BenchmarkTest00697', methods=['GET']) + def BenchmarkTest00697_get(): + return BenchmarkTest00697_post() + + @app.route('/benchmark/weakrand-02/BenchmarkTest00697', methods=['POST']) + def BenchmarkTest00697_post(): + RESPONSE = "" + + param = request.args.get("BenchmarkTest00697") + if not param: + param = "" + + bar = '' + if param: + bar = param.split(' ')[0] + + import base64 + import secrets + from helpers.utils import mysession + + num = 'BenchmarkTest00697'[13:] + user = f'SafeTheo{num}' + cookie = f'rememberMe{num}' + value = secrets.token_hex(32) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie:' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00705.py b/Samples/BenchmarkTest00705.py new file mode 100644 index 0000000..69dd29f --- /dev/null +++ b/Samples/BenchmarkTest00705.py @@ -0,0 +1,59 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-02/BenchmarkTest00705', methods=['GET']) + def BenchmarkTest00705_get(): + return BenchmarkTest00705_post() + + @app.route('/benchmark/weakrand-02/BenchmarkTest00705', methods=['POST']) + def BenchmarkTest00705_post(): + RESPONSE = "" + + param = request.args.get("BenchmarkTest00705") + if not param: + param = "" + + import html + + bar = html.escape(param) + + import random + from helpers.utils import mysession + + num = 'BenchmarkTest00705'[13:] + user = f'SafeRandall{num}' + cookie = f'rememberMe{num}' + value = str(random.SystemRandom().random())[2:] + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie: ' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00726.py b/Samples/BenchmarkTest00726.py new file mode 100644 index 0000000..a8ae68b --- /dev/null +++ b/Samples/BenchmarkTest00726.py @@ -0,0 +1,49 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/trustbound-00/BenchmarkTest00726', methods=['GET']) + def BenchmarkTest00726_get(): + return BenchmarkTest00726_post() + + @app.route('/benchmark/trustbound-00/BenchmarkTest00726', methods=['POST']) + def BenchmarkTest00726_post(): + RESPONSE = "" + + param = request.args.get("BenchmarkTest00726") + if not param: + param = "" + + num = 106 + + bar = "This_should_always_happen" if 7 * 18 + num > 200 else param + + import flask + + flask.session['userid'] = bar + + RESPONSE += ( + f'Item: \'userid\' with value \'{escape_for_html(bar)}' + '\'saved in session.' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00728.py b/Samples/BenchmarkTest00728.py new file mode 100644 index 0000000..88e2229 --- /dev/null +++ b/Samples/BenchmarkTest00728.py @@ -0,0 +1,58 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/codeinj-00/BenchmarkTest00728', methods=['GET']) + def BenchmarkTest00728_get(): + return BenchmarkTest00728_post() + + @app.route('/benchmark/codeinj-00/BenchmarkTest00728', methods=['POST']) + def BenchmarkTest00728_post(): + RESPONSE = "" + + param = request.args.get("BenchmarkTest00728") + if not param: + param = "" + + possible = "ABC" + guess = possible[0] + + match guess: + case 'A': + bar = param + case 'B': + bar = 'bob' + case 'C' | 'D': + bar = param + case _: + bar = 'bob\'s your uncle' + + try: + RESPONSE += ( + eval(bar) + ) + except: + RESPONSE += ( + f'Error evaluating expression \'{escape_for_html(bar)}\'' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00736.py b/Samples/BenchmarkTest00736.py new file mode 100644 index 0000000..8e25e13 --- /dev/null +++ b/Samples/BenchmarkTest00736.py @@ -0,0 +1,66 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/cmdi-00/BenchmarkTest00736', methods=['GET']) + def BenchmarkTest00736_get(): + return BenchmarkTest00736_post() + + @app.route('/benchmark/cmdi-00/BenchmarkTest00736', methods=['POST']) + def BenchmarkTest00736_post(): + RESPONSE = "" + + param = request.args.get("BenchmarkTest00736") + if not param: + param = "" + + map81232 = {} + map81232['keyA-81232'] = 'a-Value' + map81232['keyB-81232'] = param + map81232['keyC'] = 'another-Value' + bar = "safe!" + bar = map81232['keyB-81232'] + bar = map81232['keyA-81232'] + + import platform + import subprocess + import helpers.utils + + argStr = "" + if platform.system() == "Windows": + argStr = "cmd.exe /c " + else: + argStr = "sh -c " + argStr += f"echo {bar}" + + try: + proc = subprocess.run(argStr, shell=True, capture_output=True, encoding="utf-8") + + RESPONSE += ( + helpers.utils.commandOutput(proc) + ) + except IOError: + RESPONSE += ( + "Problem executing cmdi - subprocess.run(list) Test Case" + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00741.py b/Samples/BenchmarkTest00741.py new file mode 100644 index 0000000..54e977a --- /dev/null +++ b/Samples/BenchmarkTest00741.py @@ -0,0 +1,61 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/pathtraver-01/BenchmarkTest00741', methods=['GET']) + def BenchmarkTest00741_get(): + return BenchmarkTest00741_post() + + @app.route('/benchmark/pathtraver-01/BenchmarkTest00741', methods=['POST']) + def BenchmarkTest00741_post(): + RESPONSE = "" + + values = request.args.getlist("BenchmarkTest00741") + param = "" + if values: + param = values[0] + + num = 106 + + bar = "This should never happen" if (7*42) - num > 200 else param + + import helpers.utils + + try: + fileName = f'{helpers.utils.TESTFILES_DIR}/{bar}' + fd = open(fileName, 'wb') + RESPONSE += ( + f'Now ready to write to file: {escape_for_html(fileName)}' + ) + except IOError as e: + RESPONSE += ( + f'Problem reading from file \'{escape_for_html(fileName)}\': ' + f'{escape_for_html(e.strerror)}' + ) + finally: + try: + if fd is not None: + fd.close() + except IOError: + pass # "// we tried..." + + return RESPONSE + diff --git a/Samples/BenchmarkTest00742.py b/Samples/BenchmarkTest00742.py new file mode 100644 index 0000000..4dc3bb2 --- /dev/null +++ b/Samples/BenchmarkTest00742.py @@ -0,0 +1,56 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/pathtraver-01/BenchmarkTest00742', methods=['GET']) + def BenchmarkTest00742_get(): + return BenchmarkTest00742_post() + + @app.route('/benchmark/pathtraver-01/BenchmarkTest00742', methods=['POST']) + def BenchmarkTest00742_post(): + RESPONSE = "" + + values = request.args.getlist("BenchmarkTest00742") + param = "" + if values: + param = values[0] + + bar = "" + if param: + lst = [] + lst.append('safe') + lst.append(param) + lst.append('moresafe') + lst.pop(0) + bar = lst[0] + + import pathlib + import helpers.utils + + testfiles = pathlib.Path(helpers.utils.TESTFILES_DIR) + p = testfiles / bar + if p.exists(): + RESPONSE += ( f"File \'{escape_for_html(str(p))}\' exists." ) + else: + RESPONSE += ( f"File \'{escape_for_html(str(p))}\' does not exist." ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00744.py b/Samples/BenchmarkTest00744.py new file mode 100644 index 0000000..71f19ae --- /dev/null +++ b/Samples/BenchmarkTest00744.py @@ -0,0 +1,58 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/pathtraver-01/BenchmarkTest00744', methods=['GET']) + def BenchmarkTest00744_get(): + return BenchmarkTest00744_post() + + @app.route('/benchmark/pathtraver-01/BenchmarkTest00744', methods=['POST']) + def BenchmarkTest00744_post(): + RESPONSE = "" + + values = request.args.getlist("BenchmarkTest00744") + param = "" + if values: + param = values[0] + + num = 106 + + bar = "This should never happen" if (7*42) - num > 200 else param + + import pathlib + import helpers.utils + + testfiles = pathlib.Path(helpers.utils.TESTFILES_DIR) + p = (testfiles / bar).resolve() + + if not str(p).startswith(str(testfiles)): + RESPONSE += ( + "Invalid Path." + ) + return RESPONSE + + if p.exists(): + RESPONSE += ( f"File \'{escape_for_html(str(p))}\' exists." ) + else: + RESPONSE += ( f"File \'{escape_for_html(str(p))}\' does not exist." ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00748.py b/Samples/BenchmarkTest00748.py new file mode 100644 index 0000000..d5b3191 --- /dev/null +++ b/Samples/BenchmarkTest00748.py @@ -0,0 +1,64 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/pathtraver-01/BenchmarkTest00748', methods=['GET']) + def BenchmarkTest00748_get(): + return BenchmarkTest00748_post() + + @app.route('/benchmark/pathtraver-01/BenchmarkTest00748', methods=['POST']) + def BenchmarkTest00748_post(): + RESPONSE = "" + + values = request.args.getlist("BenchmarkTest00748") + param = "" + if values: + param = values[0] + + num = 106 + + bar = "This should never happen" if (7*42) - num > 200 else param + + import pathlib + import helpers.utils + + try: + testfiles = pathlib.Path(helpers.utils.TESTFILES_DIR) + p = (testfiles / bar).resolve() + + if not str(p).startswith(str(testfiles)): + RESPONSE += ( + "Invalid Path." + ) + return RESPONSE + + RESPONSE += ( + f'The beginning of file: \'{escape_for_html(str(p))}\' is:\n\n' + f'{escape_for_html(p.read_text()[:1000])}' + ) + except OSError: + RESPONSE += ( + f'Problem reading from file \'{{escape_for_html(fileName)}}\': ' + f'{escape_for_html(e.strerror)}' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00759.py b/Samples/BenchmarkTest00759.py new file mode 100644 index 0000000..71b2445 --- /dev/null +++ b/Samples/BenchmarkTest00759.py @@ -0,0 +1,73 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xxe-00/BenchmarkTest00759', methods=['GET']) + def BenchmarkTest00759_get(): + return BenchmarkTest00759_post() + + @app.route('/benchmark/xxe-00/BenchmarkTest00759', methods=['POST']) + def BenchmarkTest00759_post(): + RESPONSE = "" + + values = request.args.getlist("BenchmarkTest00759") + param = "" + if values: + param = values[0] + + import configparser + + bar = 'safe!' + conf89087 = configparser.ConfigParser() + conf89087.add_section('section89087') + conf89087.set('section89087', 'keyA-89087', 'a_Value') + conf89087.set('section89087', 'keyB-89087', param) + bar = conf89087.get('section89087', 'keyA-89087') + + import xml.dom.minidom + import xml.sax.handler + + try: + parser = xml.sax.make_parser() + # all features are disabled by default + parser.setFeature(xml.sax.handler.feature_external_ges, True) + + doc = xml.dom.minidom.parseString(bar, parser) + + out = '' + processing = [doc.documentElement] + while processing: + e = processing.pop(0) + if e.nodeType == xml.dom.Node.TEXT_NODE: + out += e.data + else: + processing[:0] = e.childNodes + + RESPONSE += ( + f'Your XML doc results are:
{escape_for_html(out)}' + ) + except: + RESPONSE += ( + f'There was an error reading your XML doc:
{escape_for_html(bar)}' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00765.py b/Samples/BenchmarkTest00765.py new file mode 100644 index 0000000..1778612 --- /dev/null +++ b/Samples/BenchmarkTest00765.py @@ -0,0 +1,59 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-02/BenchmarkTest00765', methods=['GET']) + def BenchmarkTest00765_get(): + return BenchmarkTest00765_post() + + @app.route('/benchmark/weakrand-02/BenchmarkTest00765', methods=['POST']) + def BenchmarkTest00765_post(): + RESPONSE = "" + + values = request.args.getlist("BenchmarkTest00765") + param = "" + if values: + param = values[0] + + import helpers.utils + bar = helpers.utils.escape_for_html(param) + + import random + from helpers.utils import mysession + + num = 'BenchmarkTest00765'[13:] + user = f'Randy{num}' + cookie = f'rememberMe{num}' + value = str(random.getrandbits(32)) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie: ' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00766.py b/Samples/BenchmarkTest00766.py new file mode 100644 index 0000000..5af52cc --- /dev/null +++ b/Samples/BenchmarkTest00766.py @@ -0,0 +1,65 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-02/BenchmarkTest00766', methods=['GET']) + def BenchmarkTest00766_get(): + return BenchmarkTest00766_post() + + @app.route('/benchmark/weakrand-02/BenchmarkTest00766', methods=['POST']) + def BenchmarkTest00766_post(): + RESPONSE = "" + + values = request.args.getlist("BenchmarkTest00766") + param = "" + if values: + param = values[0] + + bar = "alsosafe" + if param: + lst = [] + lst.append('safe') + lst.append(param) + lst.append('moresafe') + lst.pop(0) + bar = lst[1] + + import random + from helpers.utils import mysession + + num = 'BenchmarkTest00766'[13:] + user = f'Randy{num}' + cookie = f'rememberMe{num}' + value = str(random.getrandbits(32)) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie: ' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00776.py b/Samples/BenchmarkTest00776.py new file mode 100644 index 0000000..0d1f381 --- /dev/null +++ b/Samples/BenchmarkTest00776.py @@ -0,0 +1,61 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-02/BenchmarkTest00776', methods=['GET']) + def BenchmarkTest00776_get(): + return BenchmarkTest00776_post() + + @app.route('/benchmark/weakrand-02/BenchmarkTest00776', methods=['POST']) + def BenchmarkTest00776_post(): + RESPONSE = "" + + values = request.args.getlist("BenchmarkTest00776") + param = "" + if values: + param = values[0] + + string75317 = 'help' + string75317 += param + string75317 += 'snapes on a plane' + bar = string75317[4:-17] + + import secrets + from helpers.utils import mysession + + num = 'BenchmarkTest00776'[13:] + user = f'SafeRobbie{num}' + cookie = f'rememberMe{num}' + value = str(secrets.randbelow(2**32)) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie:' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00778.py b/Samples/BenchmarkTest00778.py new file mode 100644 index 0000000..d209b1a --- /dev/null +++ b/Samples/BenchmarkTest00778.py @@ -0,0 +1,65 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-02/BenchmarkTest00778', methods=['GET']) + def BenchmarkTest00778_get(): + return BenchmarkTest00778_post() + + @app.route('/benchmark/weakrand-02/BenchmarkTest00778', methods=['POST']) + def BenchmarkTest00778_post(): + RESPONSE = "" + + values = request.args.getlist("BenchmarkTest00778") + param = "" + if values: + param = values[0] + + string62476 = '' + data12 = '' + copy = string62476 + string62476 = '' + string62476 += param + copy += 'SomeOKString' + bar = copy + + import base64 + import secrets + from helpers.utils import mysession + + num = 'BenchmarkTest00778'[13:] + user = f'SafeToby{num}' + cookie = f'rememberMe{num}' + value = base64.b64encode(secrets.token_bytes(32)) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie:' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00779.py b/Samples/BenchmarkTest00779.py new file mode 100644 index 0000000..e2aad2b --- /dev/null +++ b/Samples/BenchmarkTest00779.py @@ -0,0 +1,61 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-02/BenchmarkTest00779', methods=['GET']) + def BenchmarkTest00779_get(): + return BenchmarkTest00779_post() + + @app.route('/benchmark/weakrand-02/BenchmarkTest00779', methods=['POST']) + def BenchmarkTest00779_post(): + RESPONSE = "" + + values = request.args.getlist("BenchmarkTest00779") + param = "" + if values: + param = values[0] + + num = 106 + + bar = "This should never happen" if (7*42) - num > 200 else param + + import base64 + import secrets + from helpers.utils import mysession + + num = 'BenchmarkTest00779'[13:] + user = f'SafeToby{num}' + cookie = f'rememberMe{num}' + value = base64.b64encode(secrets.token_bytes(32)) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie:' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00782.py b/Samples/BenchmarkTest00782.py new file mode 100644 index 0000000..6710052 --- /dev/null +++ b/Samples/BenchmarkTest00782.py @@ -0,0 +1,61 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-02/BenchmarkTest00782', methods=['GET']) + def BenchmarkTest00782_get(): + return BenchmarkTest00782_post() + + @app.route('/benchmark/weakrand-02/BenchmarkTest00782', methods=['POST']) + def BenchmarkTest00782_post(): + RESPONSE = "" + + values = request.args.getlist("BenchmarkTest00782") + param = "" + if values: + param = values[0] + + bar = '' + if param: + bar = param.split(' ')[0] + + import base64 + import secrets + from helpers.utils import mysession + + num = 'BenchmarkTest00782'[13:] + user = f'SafeTheo{num}' + cookie = f'rememberMe{num}' + value = secrets.token_hex(32) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie:' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00789.py b/Samples/BenchmarkTest00789.py new file mode 100644 index 0000000..cc0c38c --- /dev/null +++ b/Samples/BenchmarkTest00789.py @@ -0,0 +1,66 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-02/BenchmarkTest00789', methods=['GET']) + def BenchmarkTest00789_get(): + return BenchmarkTest00789_post() + + @app.route('/benchmark/weakrand-02/BenchmarkTest00789', methods=['POST']) + def BenchmarkTest00789_post(): + RESPONSE = "" + + values = request.args.getlist("BenchmarkTest00789") + param = "" + if values: + param = values[0] + + bar = "alsosafe" + if param: + lst = [] + lst.append('safe') + lst.append(param) + lst.append('moresafe') + lst.pop(0) + bar = lst[1] + + import random + import base64 + from helpers.utils import mysession + + num = 'BenchmarkTest00789'[13:] + user = f'SafeBarbara{num}' + cookie = f'rememberMe{num}' + value = str(base64.b64encode(random.SystemRandom().randbytes(32))) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie: ' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00811.py b/Samples/BenchmarkTest00811.py new file mode 100644 index 0000000..73834bf --- /dev/null +++ b/Samples/BenchmarkTest00811.py @@ -0,0 +1,64 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/securecookie-00/BenchmarkTest00811', methods=['GET']) + def BenchmarkTest00811_get(): + return BenchmarkTest00811_post() + + @app.route('/benchmark/securecookie-00/BenchmarkTest00811', methods=['POST']) + def BenchmarkTest00811_post(): + RESPONSE = "" + + values = request.args.getlist("BenchmarkTest00811") + param = "" + if values: + param = values[0] + + bar = '' + if param: + bar = param.split(' ')[0] + + from flask import make_response + import io + import helpers.utils + + input = '' + if isinstance(bar, str): + input = bar.encode('utf-8') + elif isinstance(bar, io.IOBase): + input = bar.read(1000) + + cookie = 'SomeCookie' + value = input.decode('utf-8') + + RESPONSE += ( + f'Created cookie: \'{cookie}\' with value \'{helpers.utils.escape_for_html(value)}\' and secure flag set to false.' + ) + + RESPONSE = make_response(RESPONSE) + RESPONSE.set_cookie(cookie, value, + path=request.path, + secure=True, + httponly=True) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00818.py b/Samples/BenchmarkTest00818.py new file mode 100644 index 0000000..2fe697a --- /dev/null +++ b/Samples/BenchmarkTest00818.py @@ -0,0 +1,57 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/codeinj-00/BenchmarkTest00818', methods=['GET']) + def BenchmarkTest00818_get(): + return BenchmarkTest00818_post() + + @app.route('/benchmark/codeinj-00/BenchmarkTest00818', methods=['POST']) + def BenchmarkTest00818_post(): + RESPONSE = "" + + values = request.args.getlist("BenchmarkTest00818") + param = "" + if values: + param = values[0] + + import helpers.ThingFactory + + thing = helpers.ThingFactory.createThing() + bar = thing.doSomething(param) + + if not bar.startswith('\'') or not bar.endswith('\'') or '\'' in bar[1:-1]: + RESPONSE += ( + "Eval argument must be a plain string literal." + ) + return RESPONSE + + try: + RESPONSE += ( + eval(bar) + ) + except: + RESPONSE += ( + f'Error evaluating expression \'{escape_for_html(bar)}\'' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00822.py b/Samples/BenchmarkTest00822.py new file mode 100644 index 0000000..80d2d72 --- /dev/null +++ b/Samples/BenchmarkTest00822.py @@ -0,0 +1,54 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/codeinj-00/BenchmarkTest00822', methods=['GET']) + def BenchmarkTest00822_get(): + return BenchmarkTest00822_post() + + @app.route('/benchmark/codeinj-00/BenchmarkTest00822', methods=['POST']) + def BenchmarkTest00822_post(): + RESPONSE = "" + + values = request.args.getlist("BenchmarkTest00822") + param = "" + if values: + param = values[0] + + num = 106 + + bar = "This should never happen" if (7*42) - num > 200 else param + + if not bar.startswith('\'') or not bar.endswith('\'') or '\'' in bar[1:-1]: + RESPONSE += ( + "Exec argument must be a plain string literal." + ) + return RESPONSE + + try: + exec(bar) + except: + RESPONSE += ( + f'Error executing statement \'{escape_for_html(bar)}\'' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00825.py b/Samples/BenchmarkTest00825.py new file mode 100644 index 0000000..1aaad46 --- /dev/null +++ b/Samples/BenchmarkTest00825.py @@ -0,0 +1,59 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/deserialization-00/BenchmarkTest00825', methods=['GET']) + def BenchmarkTest00825_get(): + return BenchmarkTest00825_post() + + @app.route('/benchmark/deserialization-00/BenchmarkTest00825', methods=['POST']) + def BenchmarkTest00825_post(): + RESPONSE = "" + + values = request.args.getlist("BenchmarkTest00825") + param = "" + if values: + param = values[0] + + bar = "This should never happen" + if 'should' in bar: + bar = param + + import pickle + import base64 + import helpers.utils + + helpers.utils.sharedstr = "no pickles to be seen here" + + try: + unpickled = pickle.loads(base64.urlsafe_b64decode(bar)) + except: + RESPONSE += ( + 'Unpickling failed!' + ) + return RESPONSE + + RESPONSE += ( + f'shared string is {helpers.utils.sharedstr}' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00834.py b/Samples/BenchmarkTest00834.py new file mode 100644 index 0000000..4148b13 --- /dev/null +++ b/Samples/BenchmarkTest00834.py @@ -0,0 +1,53 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/pathtraver-01/BenchmarkTest00834', methods=['GET']) + def BenchmarkTest00834_get(): + return BenchmarkTest00834_post() + + @app.route('/benchmark/pathtraver-01/BenchmarkTest00834', methods=['POST']) + def BenchmarkTest00834_post(): + RESPONSE = "" + + import helpers.separate_request + + wrapped = helpers.separate_request.request_wrapper(request) + param = wrapped.get_query_parameter("BenchmarkTest00834") + if not param: + param = "" + + import helpers.ThingFactory + + thing = helpers.ThingFactory.createThing() + bar = thing.doSomething(param) + + import os + import helpers.utils + + fileName = f'{helpers.utils.TESTFILES_DIR}/{bar}' + if os.path.exists(fileName): + RESPONSE += ( f"File \'{escape_for_html(fileName)}\' exists." ) + else: + RESPONSE += ( f"File \'{escape_for_html(fileName)}\' does not exist." ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00842.py b/Samples/BenchmarkTest00842.py new file mode 100644 index 0000000..84d47a6 --- /dev/null +++ b/Samples/BenchmarkTest00842.py @@ -0,0 +1,49 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xss-00/BenchmarkTest00842', methods=['GET']) + def BenchmarkTest00842_get(): + return BenchmarkTest00842_post() + + @app.route('/benchmark/xss-00/BenchmarkTest00842', methods=['POST']) + def BenchmarkTest00842_post(): + RESPONSE = "" + + import helpers.separate_request + + wrapped = helpers.separate_request.request_wrapper(request) + param = wrapped.get_query_parameter("BenchmarkTest00842") + if not param: + param = "" + + num = 106 + + bar = "This should never happen" if (7*42) - num > 200 else param + + + otherarg = "static text" + RESPONSE += ( + 'bar is \'{0}\' and otherarg is \'{1}\''.format(bar, otherarg) + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00860.py b/Samples/BenchmarkTest00860.py new file mode 100644 index 0000000..12bf2e2 --- /dev/null +++ b/Samples/BenchmarkTest00860.py @@ -0,0 +1,61 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-02/BenchmarkTest00860', methods=['GET']) + def BenchmarkTest00860_get(): + return BenchmarkTest00860_post() + + @app.route('/benchmark/weakrand-02/BenchmarkTest00860', methods=['POST']) + def BenchmarkTest00860_post(): + RESPONSE = "" + + import helpers.separate_request + + wrapped = helpers.separate_request.request_wrapper(request) + param = wrapped.get_query_parameter("BenchmarkTest00860") + if not param: + param = "" + + import helpers.utils + bar = helpers.utils.escape_for_html(param) + + import random + from helpers.utils import mysession + + num = 'BenchmarkTest00860'[13:] + user = f'Randy{num}' + cookie = f'rememberMe{num}' + value = str(random.getrandbits(32)) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie: ' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00865.py b/Samples/BenchmarkTest00865.py new file mode 100644 index 0000000..5cc9b9c --- /dev/null +++ b/Samples/BenchmarkTest00865.py @@ -0,0 +1,68 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-02/BenchmarkTest00865', methods=['GET']) + def BenchmarkTest00865_get(): + return BenchmarkTest00865_post() + + @app.route('/benchmark/weakrand-02/BenchmarkTest00865', methods=['POST']) + def BenchmarkTest00865_post(): + RESPONSE = "" + + import helpers.separate_request + + wrapped = helpers.separate_request.request_wrapper(request) + param = wrapped.get_query_parameter("BenchmarkTest00865") + if not param: + param = "" + + bar = "" + if param: + lst = [] + lst.append('safe') + lst.append(param) + lst.append('moresafe') + lst.pop(0) + bar = lst[0] + + import base64 + import secrets + from helpers.utils import mysession + + num = 'BenchmarkTest00865'[13:] + user = f'SafeToby{num}' + cookie = f'rememberMe{num}' + value = base64.b64encode(secrets.token_bytes(32)) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie:' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00866.py b/Samples/BenchmarkTest00866.py new file mode 100644 index 0000000..210f1a5 --- /dev/null +++ b/Samples/BenchmarkTest00866.py @@ -0,0 +1,64 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-02/BenchmarkTest00866', methods=['GET']) + def BenchmarkTest00866_get(): + return BenchmarkTest00866_post() + + @app.route('/benchmark/weakrand-02/BenchmarkTest00866', methods=['POST']) + def BenchmarkTest00866_post(): + RESPONSE = "" + + import helpers.separate_request + + wrapped = helpers.separate_request.request_wrapper(request) + param = wrapped.get_query_parameter("BenchmarkTest00866") + if not param: + param = "" + + string67935 = 'help' + string67935 += param + string67935 += 'snapes on a plane' + bar = string67935[4:-17] + + import base64 + import secrets + from helpers.utils import mysession + + num = 'BenchmarkTest00866'[13:] + user = f'SafeToby{num}' + cookie = f'rememberMe{num}' + value = base64.b64encode(secrets.token_bytes(32)) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie:' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00867.py b/Samples/BenchmarkTest00867.py new file mode 100644 index 0000000..5c3d02b --- /dev/null +++ b/Samples/BenchmarkTest00867.py @@ -0,0 +1,61 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-02/BenchmarkTest00867', methods=['GET']) + def BenchmarkTest00867_get(): + return BenchmarkTest00867_post() + + @app.route('/benchmark/weakrand-02/BenchmarkTest00867', methods=['POST']) + def BenchmarkTest00867_post(): + RESPONSE = "" + + import helpers.separate_request + + wrapped = helpers.separate_request.request_wrapper(request) + param = wrapped.get_query_parameter("BenchmarkTest00867") + if not param: + param = "" + + bar = param + '_SafeStuff' + + import base64 + import secrets + from helpers.utils import mysession + + num = 'BenchmarkTest00867'[13:] + user = f'SafeTruman{num}' + cookie = f'rememberMe{num}' + value = secrets.token_urlsafe(32) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie:' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00868.py b/Samples/BenchmarkTest00868.py new file mode 100644 index 0000000..7f8bc11 --- /dev/null +++ b/Samples/BenchmarkTest00868.py @@ -0,0 +1,64 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-02/BenchmarkTest00868', methods=['GET']) + def BenchmarkTest00868_get(): + return BenchmarkTest00868_post() + + @app.route('/benchmark/weakrand-02/BenchmarkTest00868', methods=['POST']) + def BenchmarkTest00868_post(): + RESPONSE = "" + + import helpers.separate_request + + wrapped = helpers.separate_request.request_wrapper(request) + param = wrapped.get_query_parameter("BenchmarkTest00868") + if not param: + param = "" + + TestParam = "This should never happen" + if 'should' not in TestParam: + bar = "Ifnot case passed" + else: + bar = param + + import random + from helpers.utils import mysession + + num = 'BenchmarkTest00868'[13:] + user = f'SafeNancy{num}' + cookie = f'rememberMe{num}' + value = str(random.SystemRandom().normalvariate())[2:] + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie: ' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00878.py b/Samples/BenchmarkTest00878.py new file mode 100644 index 0000000..1218860 --- /dev/null +++ b/Samples/BenchmarkTest00878.py @@ -0,0 +1,74 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/hash-01/BenchmarkTest00878', methods=['GET']) + def BenchmarkTest00878_get(): + return BenchmarkTest00878_post() + + @app.route('/benchmark/hash-01/BenchmarkTest00878', methods=['POST']) + def BenchmarkTest00878_post(): + RESPONSE = "" + + import helpers.separate_request + + wrapped = helpers.separate_request.request_wrapper(request) + param = wrapped.get_query_parameter("BenchmarkTest00878") + if not param: + param = "" + + bar = "alsosafe" + if param: + lst = [] + lst.append('safe') + lst.append(param) + lst.append('moresafe') + lst.pop(0) + bar = lst[1] + + import hashlib, base64 + import io, helpers.utils + + input = '' + if isinstance(bar, str): + input = bar.encode('utf-8') + elif isinstance(bar, io.IOBase): + input = bar.read(1000) + + if len(input) == 0: + RESPONSE += ( + 'Cannot generate hash: Input was empty.' + ) + return RESPONSE + + hash = hashlib.sha384() + hash.update(input) + + result = hash.digest() + f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + f.write(f'hash_value={base64.b64encode(result)}\n') + RESPONSE += ( + f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.' + ) + f.close() + + return RESPONSE + diff --git a/Samples/BenchmarkTest00883.py b/Samples/BenchmarkTest00883.py new file mode 100644 index 0000000..89e5f26 --- /dev/null +++ b/Samples/BenchmarkTest00883.py @@ -0,0 +1,56 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xss-00/BenchmarkTest00883', methods=['GET']) + def BenchmarkTest00883_get(): + return BenchmarkTest00883_post() + + @app.route('/benchmark/xss-00/BenchmarkTest00883', methods=['POST']) + def BenchmarkTest00883_post(): + RESPONSE = "" + + import helpers.separate_request + + wrapped = helpers.separate_request.request_wrapper(request) + param = wrapped.get_query_parameter("BenchmarkTest00883") + if not param: + param = "" + + bar = "alsosafe" + if param: + lst = [] + lst.append('safe') + lst.append(param) + lst.append('moresafe') + lst.pop(0) + bar = lst[1] + + + RESPONSE += ( + 'The value of the bar parameter is now in a custom header.' + ) + + RESPONSE = make_response((RESPONSE, {'yourBenchmarkTest00883': bar})) + + + return RESPONSE + diff --git a/Samples/BenchmarkTest00891.py b/Samples/BenchmarkTest00891.py new file mode 100644 index 0000000..8025e85 --- /dev/null +++ b/Samples/BenchmarkTest00891.py @@ -0,0 +1,57 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/codeinj-00/BenchmarkTest00891', methods=['GET']) + def BenchmarkTest00891_get(): + return BenchmarkTest00891_post() + + @app.route('/benchmark/codeinj-00/BenchmarkTest00891', methods=['POST']) + def BenchmarkTest00891_post(): + RESPONSE = "" + + import helpers.separate_request + + wrapped = helpers.separate_request.request_wrapper(request) + param = wrapped.get_query_parameter("BenchmarkTest00891") + if not param: + param = "" + + import configparser + + bar = 'safe!' + conf8968 = configparser.ConfigParser() + conf8968.add_section('section8968') + conf8968.set('section8968', 'keyA-8968', 'a-Value') + conf8968.set('section8968', 'keyB-8968', param) + bar = conf8968.get('section8968', 'keyB-8968') + + try: + RESPONSE += ( + eval(bar) + ) + except: + RESPONSE += ( + f'Error evaluating expression \'{escape_for_html(bar)}\'' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00898.py b/Samples/BenchmarkTest00898.py new file mode 100644 index 0000000..d49c137 --- /dev/null +++ b/Samples/BenchmarkTest00898.py @@ -0,0 +1,61 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/deserialization-00/BenchmarkTest00898', methods=['GET']) + def BenchmarkTest00898_get(): + return BenchmarkTest00898_post() + + @app.route('/benchmark/deserialization-00/BenchmarkTest00898', methods=['POST']) + def BenchmarkTest00898_post(): + RESPONSE = "" + + import helpers.separate_request + + wrapped = helpers.separate_request.request_wrapper(request) + param = wrapped.get_query_parameter("BenchmarkTest00898") + if not param: + param = "" + + bar = "This should never happen" + if 'should' in bar: + bar = param + + import pickle + import base64 + import helpers.utils + + helpers.utils.sharedstr = "no pickles to be seen here" + + try: + unpickled = pickle.loads(base64.urlsafe_b64decode(bar)) + except: + RESPONSE += ( + 'Unpickling failed!' + ) + return RESPONSE + + RESPONSE += ( + f'shared string is {helpers.utils.sharedstr}' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00920.py b/Samples/BenchmarkTest00920.py new file mode 100644 index 0000000..6caa8b1 --- /dev/null +++ b/Samples/BenchmarkTest00920.py @@ -0,0 +1,70 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/pathtraver-01/BenchmarkTest00920', methods=['GET']) + def BenchmarkTest00920_get(): + return BenchmarkTest00920_post() + + @app.route('/benchmark/pathtraver-01/BenchmarkTest00920', methods=['POST']) + def BenchmarkTest00920_post(): + RESPONSE = "" + + import urllib.parse + + query_string = request.query_string.decode('utf-8') + paramLoc = query_string.find("BenchmarkTest00920" + '=') + if paramLoc == -1: + return f"request.query_string did not contain expected parameter \'{"BenchmarkTest00920"}\'." + param = query_string[paramLoc + len("BenchmarkTest00920") + 1:] + ampLoc = param.find('&') + if ampLoc != -1: + param = param[:ampLoc] + + param = urllib.parse.unquote_plus(param) + + import configparser + + bar = 'safe!' + conf73877 = configparser.ConfigParser() + conf73877.add_section('section73877') + conf73877.set('section73877', 'keyA-73877', 'a-Value') + conf73877.set('section73877', 'keyB-73877', param) + bar = conf73877.get('section73877', 'keyB-73877') + + import pathlib + import helpers.utils + + try: + testfiles = pathlib.Path(helpers.utils.TESTFILES_DIR) + p = testfiles / bar + RESPONSE += ( + f'The beginning of file: \'{escape_for_html(str(p))}\' is:\n\n' + f'{escape_for_html(p.read_text()[:1000])}' + ) + except OSError: + RESPONSE += ( + f'Problem reading from file \'{{escape_for_html(fileName)}}\': ' + f'{escape_for_html(e.strerror)}' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00925.py b/Samples/BenchmarkTest00925.py new file mode 100644 index 0000000..44a5a94 --- /dev/null +++ b/Samples/BenchmarkTest00925.py @@ -0,0 +1,60 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xss-00/BenchmarkTest00925', methods=['GET']) + def BenchmarkTest00925_get(): + return BenchmarkTest00925_post() + + @app.route('/benchmark/xss-00/BenchmarkTest00925', methods=['POST']) + def BenchmarkTest00925_post(): + RESPONSE = "" + + import urllib.parse + + query_string = request.query_string.decode('utf-8') + paramLoc = query_string.find("BenchmarkTest00925" + '=') + if paramLoc == -1: + return f"request.query_string did not contain expected parameter \'{"BenchmarkTest00925"}\'." + param = query_string[paramLoc + len("BenchmarkTest00925") + 1:] + ampLoc = param.find('&') + if ampLoc != -1: + param = param[:ampLoc] + + param = urllib.parse.unquote_plus(param) + + import configparser + + bar = 'safe!' + conf82988 = configparser.ConfigParser() + conf82988.add_section('section82988') + conf82988.set('section82988', 'keyA-82988', 'a-Value') + conf82988.set('section82988', 'keyB-82988', param) + bar = conf82988.get('section82988', 'keyB-82988') + + + otherarg = "static text" + RESPONSE += ( + 'bar is \'%s\' and otherarg is \'%s\'' % (bar, otherarg) + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00929.py b/Samples/BenchmarkTest00929.py new file mode 100644 index 0000000..a34deca --- /dev/null +++ b/Samples/BenchmarkTest00929.py @@ -0,0 +1,84 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xpathi-01/BenchmarkTest00929', methods=['GET']) + def BenchmarkTest00929_get(): + return BenchmarkTest00929_post() + + @app.route('/benchmark/xpathi-01/BenchmarkTest00929', methods=['POST']) + def BenchmarkTest00929_post(): + RESPONSE = "" + + import urllib.parse + + query_string = request.query_string.decode('utf-8') + paramLoc = query_string.find("BenchmarkTest00929" + '=') + if paramLoc == -1: + return f"request.query_string did not contain expected parameter \'{"BenchmarkTest00929"}\'." + param = query_string[paramLoc + len("BenchmarkTest00929") + 1:] + ampLoc = param.find('&') + if ampLoc != -1: + param = param[:ampLoc] + + param = urllib.parse.unquote_plus(param) + + possible = "ABC" + guess = possible[1] + + match guess: + case 'A': + bar = param + case 'B': + bar = 'bob' + case 'C' | 'D': + bar = param + case _: + bar = 'bob\'s your uncle' + + import elementpath + import xml.etree.ElementTree as ET + import helpers.utils + + if '\'' in bar: + RESPONSE += ( + "Employee ID must not contain apostrophes" + ) + return RESPONSE + + try: + root = ET.parse(f'{helpers.utils.RES_DIR}/employees.xml') + query = f"/Employees/Employee[@emplid=\'{bar}\']" + nodes = elementpath.select(root, query) + node_strings = [] + for node in nodes: + node_strings.append(' '.join([e.text for e in node])) + + RESPONSE += ( + f'Your XPATH query results are:
[ {', '.join(node_strings)} ]' + ) + except: + RESPONSE += ( + f'Error parsing XPath Query: \'{escape_for_html(query)}\'' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00930.py b/Samples/BenchmarkTest00930.py new file mode 100644 index 0000000..40dda6a --- /dev/null +++ b/Samples/BenchmarkTest00930.py @@ -0,0 +1,76 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xxe-00/BenchmarkTest00930', methods=['GET']) + def BenchmarkTest00930_get(): + return BenchmarkTest00930_post() + + @app.route('/benchmark/xxe-00/BenchmarkTest00930', methods=['POST']) + def BenchmarkTest00930_post(): + RESPONSE = "" + + import urllib.parse + + query_string = request.query_string.decode('utf-8') + paramLoc = query_string.find("BenchmarkTest00930" + '=') + if paramLoc == -1: + return f"request.query_string did not contain expected parameter \'{"BenchmarkTest00930"}\'." + param = query_string[paramLoc + len("BenchmarkTest00930") + 1:] + ampLoc = param.find('&') + if ampLoc != -1: + param = param[:ampLoc] + + param = urllib.parse.unquote_plus(param) + + import base64 + tmp = base64.b64encode(param.encode('utf-8')) + bar = base64.b64decode(tmp).decode('utf-8') + + import xml.dom.minidom + import xml.sax.handler + + try: + parser = xml.sax.make_parser() + # all features are disabled by default + parser.setFeature(xml.sax.handler.feature_external_ges, True) + + doc = xml.dom.minidom.parseString(bar, parser) + + out = '' + processing = [doc.documentElement] + while processing: + e = processing.pop(0) + if e.nodeType == xml.dom.Node.TEXT_NODE: + out += e.data + else: + processing[:0] = e.childNodes + + RESPONSE += ( + f'Your XML doc results are:
{escape_for_html(out)}' + ) + except: + RESPONSE += ( + f'There was an error reading your XML doc:
{escape_for_html(bar)}' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00940.py b/Samples/BenchmarkTest00940.py new file mode 100644 index 0000000..7cb897f --- /dev/null +++ b/Samples/BenchmarkTest00940.py @@ -0,0 +1,73 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xpathi-01/BenchmarkTest00940', methods=['GET']) + def BenchmarkTest00940_get(): + return BenchmarkTest00940_post() + + @app.route('/benchmark/xpathi-01/BenchmarkTest00940', methods=['POST']) + def BenchmarkTest00940_post(): + RESPONSE = "" + + import urllib.parse + + query_string = request.query_string.decode('utf-8') + paramLoc = query_string.find("BenchmarkTest00940" + '=') + if paramLoc == -1: + return f"request.query_string did not contain expected parameter \'{"BenchmarkTest00940"}\'." + param = query_string[paramLoc + len("BenchmarkTest00940") + 1:] + ampLoc = param.find('&') + if ampLoc != -1: + param = param[:ampLoc] + + param = urllib.parse.unquote_plus(param) + + map33295 = {} + map33295['keyA-33295'] = 'a-Value' + map33295['keyB-33295'] = param + map33295['keyC'] = 'another-Value' + bar = "safe!" + bar = map33295['keyB-33295'] + bar = map33295['keyA-33295'] + + import lxml.etree + import helpers.utils + + try: + fd = open(f'{helpers.utils.RES_DIR}/employees.xml', 'rb') + root = lxml.etree.parse(fd) + query = f'/Employees/Employee[@emplid=$name]' + nodes = root.xpath(query, name=bar) + node_strings = [] + for node in nodes: + node_strings.append(' '.join([e.text for e in node])) + + RESPONSE += ( + f'Your XPATH query results are:
[ {', '.join(node_strings)} ]' + ) + except: + RESPONSE += ( + f'Error parsing XPath Query: \'{escape_for_html(query)}\'' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00941.py b/Samples/BenchmarkTest00941.py new file mode 100644 index 0000000..ce6bbff --- /dev/null +++ b/Samples/BenchmarkTest00941.py @@ -0,0 +1,74 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xpathi-01/BenchmarkTest00941', methods=['GET']) + def BenchmarkTest00941_get(): + return BenchmarkTest00941_post() + + @app.route('/benchmark/xpathi-01/BenchmarkTest00941', methods=['POST']) + def BenchmarkTest00941_post(): + RESPONSE = "" + + import urllib.parse + + query_string = request.query_string.decode('utf-8') + paramLoc = query_string.find("BenchmarkTest00941" + '=') + if paramLoc == -1: + return f"request.query_string did not contain expected parameter \'{"BenchmarkTest00941"}\'." + param = query_string[paramLoc + len("BenchmarkTest00941") + 1:] + ampLoc = param.find('&') + if ampLoc != -1: + param = param[:ampLoc] + + param = urllib.parse.unquote_plus(param) + + bar = "alsosafe" + if param: + lst = [] + lst.append('safe') + lst.append(param) + lst.append('moresafe') + lst.pop(0) + bar = lst[1] + + import lxml.etree + import helpers.utils + + try: + fd = open(f'{helpers.utils.RES_DIR}/employees.xml', 'rb') + root = lxml.etree.parse(fd) + query = f'/Employees/Employee[@emplid=$name]' + nodes = root.xpath(query, name=bar) + node_strings = [] + for node in nodes: + node_strings.append(' '.join([e.text for e in node])) + + RESPONSE += ( + f'Your XPATH query results are:
[ {', '.join(node_strings)} ]' + ) + except: + RESPONSE += ( + f'Error parsing XPath Query: \'{escape_for_html(query)}\'' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00947.py b/Samples/BenchmarkTest00947.py new file mode 100644 index 0000000..450b30b --- /dev/null +++ b/Samples/BenchmarkTest00947.py @@ -0,0 +1,68 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-03/BenchmarkTest00947', methods=['GET']) + def BenchmarkTest00947_get(): + return BenchmarkTest00947_post() + + @app.route('/benchmark/weakrand-03/BenchmarkTest00947', methods=['POST']) + def BenchmarkTest00947_post(): + RESPONSE = "" + + import urllib.parse + + query_string = request.query_string.decode('utf-8') + paramLoc = query_string.find("BenchmarkTest00947" + '=') + if paramLoc == -1: + return f"request.query_string did not contain expected parameter \'{"BenchmarkTest00947"}\'." + param = query_string[paramLoc + len("BenchmarkTest00947") + 1:] + ampLoc = param.find('&') + if ampLoc != -1: + param = param[:ampLoc] + + param = urllib.parse.unquote_plus(param) + + import base64 + tmp = base64.b64encode(param.encode('utf-8')) + bar = base64.b64decode(tmp).decode('utf-8') + + import random + from helpers.utils import mysession + + num = 'BenchmarkTest00947'[13:] + user = f'Nancy{num}' + cookie = f'rememberMe{num}' + value = str(random.normalvariate())[2:] + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie: ' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00957.py b/Samples/BenchmarkTest00957.py new file mode 100644 index 0000000..7653633 --- /dev/null +++ b/Samples/BenchmarkTest00957.py @@ -0,0 +1,72 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-03/BenchmarkTest00957', methods=['GET']) + def BenchmarkTest00957_get(): + return BenchmarkTest00957_post() + + @app.route('/benchmark/weakrand-03/BenchmarkTest00957', methods=['POST']) + def BenchmarkTest00957_post(): + RESPONSE = "" + + import urllib.parse + + query_string = request.query_string.decode('utf-8') + paramLoc = query_string.find("BenchmarkTest00957" + '=') + if paramLoc == -1: + return f"request.query_string did not contain expected parameter \'{"BenchmarkTest00957"}\'." + param = query_string[paramLoc + len("BenchmarkTest00957") + 1:] + ampLoc = param.find('&') + if ampLoc != -1: + param = param[:ampLoc] + + param = urllib.parse.unquote_plus(param) + + num = 86 + + if 7 * 42 - num > 200: + bar = 'This_should_always_happen' + else: + bar = param + + import base64 + import secrets + from helpers.utils import mysession + + num = 'BenchmarkTest00957'[13:] + user = f'SafeToby{num}' + cookie = f'rememberMe{num}' + value = base64.b64encode(secrets.token_bytes(32)) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie:' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00959.py b/Samples/BenchmarkTest00959.py new file mode 100644 index 0000000..cf32e1a --- /dev/null +++ b/Samples/BenchmarkTest00959.py @@ -0,0 +1,71 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-03/BenchmarkTest00959', methods=['GET']) + def BenchmarkTest00959_get(): + return BenchmarkTest00959_post() + + @app.route('/benchmark/weakrand-03/BenchmarkTest00959', methods=['POST']) + def BenchmarkTest00959_post(): + RESPONSE = "" + + import urllib.parse + + query_string = request.query_string.decode('utf-8') + paramLoc = query_string.find("BenchmarkTest00959" + '=') + if paramLoc == -1: + return f"request.query_string did not contain expected parameter \'{"BenchmarkTest00959"}\'." + param = query_string[paramLoc + len("BenchmarkTest00959") + 1:] + ampLoc = param.find('&') + if ampLoc != -1: + param = param[:ampLoc] + + param = urllib.parse.unquote_plus(param) + + map2927 = {} + map2927['keyA-2927'] = 'a-Value' + map2927['keyB-2927'] = param + map2927['keyC'] = 'another-Value' + bar = map2927['keyB-2927'] + + import base64 + import secrets + from helpers.utils import mysession + + num = 'BenchmarkTest00959'[13:] + user = f'SafeTruman{num}' + cookie = f'rememberMe{num}' + value = secrets.token_urlsafe(32) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie:' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00969.py b/Samples/BenchmarkTest00969.py new file mode 100644 index 0000000..35c3e59 --- /dev/null +++ b/Samples/BenchmarkTest00969.py @@ -0,0 +1,66 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-03/BenchmarkTest00969', methods=['GET']) + def BenchmarkTest00969_get(): + return BenchmarkTest00969_post() + + @app.route('/benchmark/weakrand-03/BenchmarkTest00969', methods=['POST']) + def BenchmarkTest00969_post(): + RESPONSE = "" + + import urllib.parse + + query_string = request.query_string.decode('utf-8') + paramLoc = query_string.find("BenchmarkTest00969" + '=') + if paramLoc == -1: + return f"request.query_string did not contain expected parameter \'{"BenchmarkTest00969"}\'." + param = query_string[paramLoc + len("BenchmarkTest00969") + 1:] + ampLoc = param.find('&') + if ampLoc != -1: + param = param[:ampLoc] + + param = urllib.parse.unquote_plus(param) + + bar = param + + import random + from helpers.utils import mysession + + num = 'BenchmarkTest00969'[13:] + user = f'SafeIsaac{num}' + cookie = f'rememberMe{num}' + value = str(random.SystemRandom().randint(0, 2**32)) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie: ' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00974.py b/Samples/BenchmarkTest00974.py new file mode 100644 index 0000000..388814e --- /dev/null +++ b/Samples/BenchmarkTest00974.py @@ -0,0 +1,74 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/hash-01/BenchmarkTest00974', methods=['GET']) + def BenchmarkTest00974_get(): + return BenchmarkTest00974_post() + + @app.route('/benchmark/hash-01/BenchmarkTest00974', methods=['POST']) + def BenchmarkTest00974_post(): + RESPONSE = "" + + import urllib.parse + + query_string = request.query_string.decode('utf-8') + paramLoc = query_string.find("BenchmarkTest00974" + '=') + if paramLoc == -1: + return f"request.query_string did not contain expected parameter \'{"BenchmarkTest00974"}\'." + param = query_string[paramLoc + len("BenchmarkTest00974") + 1:] + ampLoc = param.find('&') + if ampLoc != -1: + param = param[:ampLoc] + + param = urllib.parse.unquote_plus(param) + + import helpers.utils + bar = helpers.utils.escape_for_html(param) + + import hashlib, base64 + import io, helpers.utils + + input = '' + if isinstance(bar, str): + input = bar.encode('utf-8') + elif isinstance(bar, io.IOBase): + input = bar.read(1000) + + if len(input) == 0: + RESPONSE += ( + 'Cannot generate hash: Input was empty.' + ) + return RESPONSE + + hash = hashlib.new('md5') + hash.update(input) + + result = hash.digest() + f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + f.write(f'hash_value={base64.b64encode(result)}\n') + RESPONSE += ( + f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.' + ) + f.close() + + return RESPONSE + diff --git a/Samples/BenchmarkTest00995.py b/Samples/BenchmarkTest00995.py new file mode 100644 index 0000000..724ca5f --- /dev/null +++ b/Samples/BenchmarkTest00995.py @@ -0,0 +1,62 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/deserialization-00/BenchmarkTest00995', methods=['GET']) + def BenchmarkTest00995_get(): + return BenchmarkTest00995_post() + + @app.route('/benchmark/deserialization-00/BenchmarkTest00995', methods=['POST']) + def BenchmarkTest00995_post(): + RESPONSE = "" + + import urllib.parse + + query_string = request.query_string.decode('utf-8') + paramLoc = query_string.find("BenchmarkTest00995" + '=') + if paramLoc == -1: + return f"request.query_string did not contain expected parameter \'{"BenchmarkTest00995"}\'." + param = query_string[paramLoc + len("BenchmarkTest00995") + 1:] + ampLoc = param.find('&') + if ampLoc != -1: + param = param[:ampLoc] + + param = urllib.parse.unquote_plus(param) + + num = 106 + + bar = "This_should_always_happen" if 7 * 18 + num > 200 else param + + import yaml + + try: + yobj = yaml.load(bar, Loader=yaml.Loader) + + RESPONSE += ( + yobj['text'] + ) + except: + RESPONSE += ( + "There was an error loading the configuration" + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest00996.py b/Samples/BenchmarkTest00996.py new file mode 100644 index 0000000..c4ac74d --- /dev/null +++ b/Samples/BenchmarkTest00996.py @@ -0,0 +1,66 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/deserialization-00/BenchmarkTest00996', methods=['GET']) + def BenchmarkTest00996_get(): + return BenchmarkTest00996_post() + + @app.route('/benchmark/deserialization-00/BenchmarkTest00996', methods=['POST']) + def BenchmarkTest00996_post(): + RESPONSE = "" + + import urllib.parse + + query_string = request.query_string.decode('utf-8') + paramLoc = query_string.find("BenchmarkTest00996" + '=') + if paramLoc == -1: + return f"request.query_string did not contain expected parameter \'{"BenchmarkTest00996"}\'." + param = query_string[paramLoc + len("BenchmarkTest00996") + 1:] + ampLoc = param.find('&') + if ampLoc != -1: + param = param[:ampLoc] + + param = urllib.parse.unquote_plus(param) + + map4033 = {} + map4033['keyA-4033'] = 'a-Value' + map4033['keyB-4033'] = param + map4033['keyC'] = 'another-Value' + bar = "safe!" + bar = map4033['keyB-4033'] + bar = map4033['keyA-4033'] + + import yaml + + try: + yobj = yaml.safe_load(bar) + + RESPONSE += ( + yobj['text'] + ) + except: + RESPONSE += ( + "There was an error loading the configuration" + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest01001.py b/Samples/BenchmarkTest01001.py new file mode 100644 index 0000000..7beb314 --- /dev/null +++ b/Samples/BenchmarkTest01001.py @@ -0,0 +1,51 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xss-00/BenchmarkTest01001', methods=['GET']) + def BenchmarkTest01001_get(): + return BenchmarkTest01001_post() + + @app.route('/benchmark/xss-00/BenchmarkTest01001', methods=['POST']) + def BenchmarkTest01001_post(): + RESPONSE = "" + + parts = request.path.split("/") + param = parts[1] + if not param: + param = "" + + bar = "" + if param: + lst = [] + lst.append('safe') + lst.append(param) + lst.append('moresafe') + lst.pop(0) + bar = lst[0] + + + RESPONSE += ( + f'Parameter value: {bar}' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest01011.py b/Samples/BenchmarkTest01011.py new file mode 100644 index 0000000..4a843d5 --- /dev/null +++ b/Samples/BenchmarkTest01011.py @@ -0,0 +1,69 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/pathtraver-01/BenchmarkTest01011', methods=['GET']) + def BenchmarkTest01011_get(): + return BenchmarkTest01011_post() + + @app.route('/benchmark/pathtraver-01/BenchmarkTest01011', methods=['POST']) + def BenchmarkTest01011_post(): + RESPONSE = "" + + parts = request.path.split("/") + param = parts[1] + if not param: + param = "" + + import configparser + + bar = 'safe!' + conf92400 = configparser.ConfigParser() + conf92400.add_section('section92400') + conf92400.set('section92400', 'keyA-92400', 'a_Value') + conf92400.set('section92400', 'keyB-92400', param) + bar = conf92400.get('section92400', 'keyA-92400') + + import pathlib + import helpers.utils + + try: + testfiles = pathlib.Path(helpers.utils.TESTFILES_DIR) + p = (testfiles / bar).resolve() + + if not str(p).startswith(str(testfiles)): + RESPONSE += ( + "Invalid Path." + ) + return RESPONSE + + RESPONSE += ( + f'The beginning of file: \'{escape_for_html(str(p))}\' is:\n\n' + f'{escape_for_html(p.read_text()[:1000])}' + ) + except OSError: + RESPONSE += ( + f'Problem reading from file \'{{escape_for_html(fileName)}}\': ' + f'{escape_for_html(e.strerror)}' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest01023.py b/Samples/BenchmarkTest01023.py new file mode 100644 index 0000000..1d7f9ab --- /dev/null +++ b/Samples/BenchmarkTest01023.py @@ -0,0 +1,70 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xpathi-01/BenchmarkTest01023', methods=['GET']) + def BenchmarkTest01023_get(): + return BenchmarkTest01023_post() + + @app.route('/benchmark/xpathi-01/BenchmarkTest01023', methods=['POST']) + def BenchmarkTest01023_post(): + RESPONSE = "" + + parts = request.path.split("/") + param = parts[1] + if not param: + param = "" + + possible = "ABC" + guess = possible[0] + + match guess: + case 'A': + bar = param + case 'B': + bar = 'bob' + case 'C' | 'D': + bar = param + case _: + bar = 'bob\'s your uncle' + + import elementpath + import xml.etree.ElementTree as ET + import helpers.utils + + try: + root = ET.parse(f'{helpers.utils.RES_DIR}/employees.xml') + nodes = elementpath.select(root, f"/Employees/Employee[@emplid=\'{bar.replace('\'', ''')}\']") + node_strings = [] + for node in nodes: + node_strings.append(' '.join([e.text for e in node])) + + RESPONSE += ( + f'Your XPATH query results are:
[ {', '.join(node_strings)} ]' + ) + except: + RESPONSE += ( + f'Error parsing XPath Query: \'{escape_for_html(query)}\'' + ) + + + return RESPONSE + diff --git a/Samples/BenchmarkTest01026.py b/Samples/BenchmarkTest01026.py new file mode 100644 index 0000000..db21d0b --- /dev/null +++ b/Samples/BenchmarkTest01026.py @@ -0,0 +1,61 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xpathi-01/BenchmarkTest01026', methods=['GET']) + def BenchmarkTest01026_get(): + return BenchmarkTest01026_post() + + @app.route('/benchmark/xpathi-01/BenchmarkTest01026', methods=['POST']) + def BenchmarkTest01026_post(): + RESPONSE = "" + + parts = request.path.split("/") + param = parts[1] + if not param: + param = "" + + import base64 + tmp = base64.b64encode(param.encode('utf-8')) + bar = base64.b64decode(tmp).decode('utf-8') + + import lxml.etree + import helpers.utils + + try: + fd = open(f'{helpers.utils.RES_DIR}/employees.xml', 'rb') + root = lxml.etree.parse(fd) + query = f'/Employees/Employee[@emplid=\'{bar}\']' + nodes = root.xpath(query) + node_strings = [] + for node in nodes: + node_strings.append(' '.join([e.text for e in node])) + + RESPONSE += ( + f'Your XPATH query results are:
[ {', '.join(node_strings)} ]' + ) + except: + RESPONSE += ( + f'Error parsing XPath Query: \'{escape_for_html(query)}\'' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest01035.py b/Samples/BenchmarkTest01035.py new file mode 100644 index 0000000..d202a2e --- /dev/null +++ b/Samples/BenchmarkTest01035.py @@ -0,0 +1,62 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xpathi-02/BenchmarkTest01035', methods=['GET']) + def BenchmarkTest01035_get(): + return BenchmarkTest01035_post() + + @app.route('/benchmark/xpathi-02/BenchmarkTest01035', methods=['POST']) + def BenchmarkTest01035_post(): + RESPONSE = "" + + parts = request.path.split("/") + param = parts[1] + if not param: + param = "" + + string60666 = 'help' + string60666 += param + string60666 += 'snapes on a plane' + bar = string60666[4:-17] + + import lxml.etree + import helpers.utils + + try: + fd = open(f'{helpers.utils.RES_DIR}/employees.xml', 'rb') + root = lxml.etree.parse(fd) + query = f'/Employees/Employee[@emplid=$name]' + nodes = root.xpath(query, name=bar) + node_strings = [] + for node in nodes: + node_strings.append(' '.join([e.text for e in node])) + + RESPONSE += ( + f'Your XPATH query results are:
[ {', '.join(node_strings)} ]' + ) + except: + RESPONSE += ( + f'Error parsing XPath Query: \'{escape_for_html(query)}\'' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest01040.py b/Samples/BenchmarkTest01040.py new file mode 100644 index 0000000..03251e5 --- /dev/null +++ b/Samples/BenchmarkTest01040.py @@ -0,0 +1,59 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-03/BenchmarkTest01040', methods=['GET']) + def BenchmarkTest01040_get(): + return BenchmarkTest01040_post() + + @app.route('/benchmark/weakrand-03/BenchmarkTest01040', methods=['POST']) + def BenchmarkTest01040_post(): + RESPONSE = "" + + parts = request.path.split("/") + param = parts[1] + if not param: + param = "" + + import helpers.utils + bar = helpers.utils.escape_for_html(param) + + import random + from helpers.utils import mysession + + num = 'BenchmarkTest01040'[13:] + user = f'Randy{num}' + cookie = f'rememberMe{num}' + value = str(random.getrandbits(32)) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie: ' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest01044.py b/Samples/BenchmarkTest01044.py new file mode 100644 index 0000000..2f6f1c5 --- /dev/null +++ b/Samples/BenchmarkTest01044.py @@ -0,0 +1,66 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-03/BenchmarkTest01044', methods=['GET']) + def BenchmarkTest01044_get(): + return BenchmarkTest01044_post() + + @app.route('/benchmark/weakrand-03/BenchmarkTest01044', methods=['POST']) + def BenchmarkTest01044_post(): + RESPONSE = "" + + parts = request.path.split("/") + param = parts[1] + if not param: + param = "" + + bar = "" + if param: + lst = [] + lst.append('safe') + lst.append(param) + lst.append('moresafe') + lst.pop(0) + bar = lst[0] + + import random + import base64 + from helpers.utils import mysession + + num = 'BenchmarkTest01044'[13:] + user = f'Barbara{num}' + cookie = f'rememberMe{num}' + value = str(base64.b64encode(random.randbytes(32))) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie: ' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest01053.py b/Samples/BenchmarkTest01053.py new file mode 100644 index 0000000..3259dfb --- /dev/null +++ b/Samples/BenchmarkTest01053.py @@ -0,0 +1,66 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-03/BenchmarkTest01053', methods=['GET']) + def BenchmarkTest01053_get(): + return BenchmarkTest01053_post() + + @app.route('/benchmark/weakrand-03/BenchmarkTest01053', methods=['POST']) + def BenchmarkTest01053_post(): + RESPONSE = "" + + parts = request.path.split("/") + param = parts[1] + if not param: + param = "" + + import configparser + + bar = 'safe!' + conf78986 = configparser.ConfigParser() + conf78986.add_section('section78986') + conf78986.set('section78986', 'keyA-78986', 'a-Value') + conf78986.set('section78986', 'keyB-78986', param) + bar = conf78986.get('section78986', 'keyB-78986') + + import base64 + import secrets + from helpers.utils import mysession + + num = 'BenchmarkTest01053'[13:] + user = f'SafeToby{num}' + cookie = f'rememberMe{num}' + value = base64.b64encode(secrets.token_bytes(32)) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie:' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest01060.py b/Samples/BenchmarkTest01060.py new file mode 100644 index 0000000..5426078 --- /dev/null +++ b/Samples/BenchmarkTest01060.py @@ -0,0 +1,62 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-03/BenchmarkTest01060', methods=['GET']) + def BenchmarkTest01060_get(): + return BenchmarkTest01060_post() + + @app.route('/benchmark/weakrand-03/BenchmarkTest01060', methods=['POST']) + def BenchmarkTest01060_post(): + RESPONSE = "" + + parts = request.path.split("/") + param = parts[1] + if not param: + param = "" + + import helpers.ThingFactory + + thing = helpers.ThingFactory.createThing() + bar = thing.doSomething(param) + + import base64 + import secrets + from helpers.utils import mysession + + num = 'BenchmarkTest01060'[13:] + user = f'SafeTruman{num}' + cookie = f'rememberMe{num}' + value = secrets.token_urlsafe(32) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie:' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest01081.py b/Samples/BenchmarkTest01081.py new file mode 100644 index 0000000..65e054d --- /dev/null +++ b/Samples/BenchmarkTest01081.py @@ -0,0 +1,68 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/hash-01/BenchmarkTest01081', methods=['GET']) + def BenchmarkTest01081_get(): + return BenchmarkTest01081_post() + + @app.route('/benchmark/hash-01/BenchmarkTest01081', methods=['POST']) + def BenchmarkTest01081_post(): + RESPONSE = "" + + parts = request.path.split("/") + param = parts[1] + if not param: + param = "" + + import helpers.ThingFactory + + thing = helpers.ThingFactory.createThing() + bar = thing.doSomething(param) + + import hashlib, base64 + import io, helpers.utils + + input = '' + if isinstance(bar, str): + input = bar.encode('utf-8') + elif isinstance(bar, io.IOBase): + input = bar.read(1000) + + if len(input) == 0: + RESPONSE += ( + 'Cannot generate hash: Input was empty.' + ) + return RESPONSE + + hash = hashlib.sha512() + hash.update(input) + + result = hash.digest() + f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + f.write(f'hash_value={base64.b64encode(result)}\n') + RESPONSE += ( + f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.' + ) + f.close() + + return RESPONSE + diff --git a/Samples/BenchmarkTest01084.py b/Samples/BenchmarkTest01084.py new file mode 100644 index 0000000..34af92a --- /dev/null +++ b/Samples/BenchmarkTest01084.py @@ -0,0 +1,48 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xss-01/BenchmarkTest01084', methods=['GET']) + def BenchmarkTest01084_get(): + return BenchmarkTest01084_post() + + @app.route('/benchmark/xss-01/BenchmarkTest01084', methods=['POST']) + def BenchmarkTest01084_post(): + RESPONSE = "" + + parts = request.path.split("/") + param = parts[1] + if not param: + param = "" + + superstring = f'58606{param}abcd' + bar = superstring[len('58606'):len(superstring)-5] + + + RESPONSE += ( + 'The value of the bar parameter is now in a custom header.' + ) + + RESPONSE = make_response((RESPONSE, {'yourBenchmarkTest01084': bar})) + + + return RESPONSE + diff --git a/Samples/BenchmarkTest01087.py b/Samples/BenchmarkTest01087.py new file mode 100644 index 0000000..ef2e235 --- /dev/null +++ b/Samples/BenchmarkTest01087.py @@ -0,0 +1,64 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/securecookie-00/BenchmarkTest01087', methods=['GET']) + def BenchmarkTest01087_get(): + return BenchmarkTest01087_post() + + @app.route('/benchmark/securecookie-00/BenchmarkTest01087', methods=['POST']) + def BenchmarkTest01087_post(): + RESPONSE = "" + + parts = request.path.split("/") + param = parts[1] + if not param: + param = "" + + bar = '' + if param: + bar = param.split(' ')[0] + + from flask import make_response + import io + import helpers.utils + + input = '' + if isinstance(bar, str): + input = bar.encode('utf-8') + elif isinstance(bar, io.IOBase): + input = bar.read(1000) + + cookie = 'SomeCookie' + value = input.decode('utf-8') + + RESPONSE += ( + f'Created cookie: \'{cookie}\' with value \'{helpers.utils.escape_for_html(value)}\' and secure flag set to false.' + ) + + RESPONSE = make_response(RESPONSE) + RESPONSE.set_cookie(cookie, value, + path=request.path, + secure=False, + httponly=True) + + return RESPONSE + diff --git a/Samples/BenchmarkTest01091.py b/Samples/BenchmarkTest01091.py new file mode 100644 index 0000000..3ec4d8f --- /dev/null +++ b/Samples/BenchmarkTest01091.py @@ -0,0 +1,60 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/redirect-00/BenchmarkTest01091', methods=['GET']) + def BenchmarkTest01091_get(): + return BenchmarkTest01091_post() + + @app.route('/benchmark/redirect-00/BenchmarkTest01091', methods=['POST']) + def BenchmarkTest01091_post(): + RESPONSE = "" + + parts = request.path.split("/") + param = parts[1] + if not param: + param = "" + + import helpers.ThingFactory + + thing = helpers.ThingFactory.createThing() + bar = thing.doSomething(param) + + import flask + import urllib.parse + + try: + url = urllib.parse.urlparse(bar) + if url.netloc not in ['google.com'] or url.scheme != 'https': + RESPONSE += ( + 'Invalid URL.' + ) + return RESPONSE + except: + RESPONSE += ( + 'Error parsing URL.' + ) + return RESPONSE + + return flask.redirect(bar) + + return RESPONSE + diff --git a/Samples/BenchmarkTest01094.py b/Samples/BenchmarkTest01094.py new file mode 100644 index 0000000..309c200 --- /dev/null +++ b/Samples/BenchmarkTest01094.py @@ -0,0 +1,49 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/trustbound-00/BenchmarkTest01094', methods=['GET']) + def BenchmarkTest01094_get(): + return BenchmarkTest01094_post() + + @app.route('/benchmark/trustbound-00/BenchmarkTest01094', methods=['POST']) + def BenchmarkTest01094_post(): + RESPONSE = "" + + parts = request.path.split("/") + param = parts[1] + if not param: + param = "" + + superstring = f'36072{param}abcd' + bar = superstring[len('36072'):len(superstring)-5] + + import flask + + flask.session[bar] = '12345' + + RESPONSE += ( + f'Item: \'{escape_for_html(bar)}' + '\' with value: 12345 saved in session.' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest01099.py b/Samples/BenchmarkTest01099.py new file mode 100644 index 0000000..35a8493 --- /dev/null +++ b/Samples/BenchmarkTest01099.py @@ -0,0 +1,58 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/deserialization-00/BenchmarkTest01099', methods=['GET']) + def BenchmarkTest01099_get(): + return BenchmarkTest01099_post() + + @app.route('/benchmark/deserialization-00/BenchmarkTest01099', methods=['POST']) + def BenchmarkTest01099_post(): + RESPONSE = "" + + parts = request.path.split("/") + param = parts[1] + if not param: + param = "" + + string28092 = '' + data12 = '' + copy = string28092 + string28092 = '' + string28092 += param + copy += 'SomeOKString' + bar = copy + + import yaml + + try: + yobj = yaml.load(bar, Loader=yaml.Loader) + + RESPONSE += ( + yobj['text'] + ) + except: + RESPONSE += ( + "There was an error loading the configuration" + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest01100.py b/Samples/BenchmarkTest01100.py new file mode 100644 index 0000000..72846d5 --- /dev/null +++ b/Samples/BenchmarkTest01100.py @@ -0,0 +1,59 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/deserialization-00/BenchmarkTest01100', methods=['GET']) + def BenchmarkTest01100_get(): + return BenchmarkTest01100_post() + + @app.route('/benchmark/deserialization-00/BenchmarkTest01100', methods=['POST']) + def BenchmarkTest01100_post(): + RESPONSE = "" + + parts = request.path.split("/") + param = parts[1] + if not param: + param = "" + + import configparser + + bar = 'safe!' + conf30057 = configparser.ConfigParser() + conf30057.add_section('section30057') + conf30057.set('section30057', 'keyA-30057', 'a_Value') + conf30057.set('section30057', 'keyB-30057', param) + bar = conf30057.get('section30057', 'keyA-30057') + + import yaml + + try: + yobj = yaml.safe_load(bar) + + RESPONSE += ( + yobj['text'] + ) + except: + RESPONSE += ( + "There was an error loading the configuration" + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest01104.py b/Samples/BenchmarkTest01104.py new file mode 100644 index 0000000..8f86674 --- /dev/null +++ b/Samples/BenchmarkTest01104.py @@ -0,0 +1,46 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xss-01/BenchmarkTest01104', methods=['GET']) + def BenchmarkTest01104_get(): + return BenchmarkTest01104_post() + + @app.route('/benchmark/xss-01/BenchmarkTest01104', methods=['POST']) + def BenchmarkTest01104_post(): + RESPONSE = "" + + import helpers.separate_request + scr = helpers.separate_request.request_wrapper(request) + param = scr.get_safe_value("BenchmarkTest01104") + + import helpers.ThingFactory + + thing = helpers.ThingFactory.createThing() + bar = thing.doSomething(param) + + + RESPONSE += ( + f'Parameter value: {bar}' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest01105.py b/Samples/BenchmarkTest01105.py new file mode 100644 index 0000000..3d4a5ec --- /dev/null +++ b/Samples/BenchmarkTest01105.py @@ -0,0 +1,68 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/pathtraver-01/BenchmarkTest01105', methods=['GET']) + def BenchmarkTest01105_get(): + return BenchmarkTest01105_post() + + @app.route('/benchmark/pathtraver-01/BenchmarkTest01105', methods=['POST']) + def BenchmarkTest01105_post(): + RESPONSE = "" + + import helpers.separate_request + scr = helpers.separate_request.request_wrapper(request) + param = scr.get_safe_value("BenchmarkTest01105") + + map12023 = {} + map12023['keyA-12023'] = 'a-Value' + map12023['keyB-12023'] = param + map12023['keyC'] = 'another-Value' + bar = "safe!" + bar = map12023['keyB-12023'] + bar = map12023['keyA-12023'] + + import helpers.utils + + fileName = None + fd = None + + try: + fileName = f'{helpers.utils.TESTFILES_DIR}/{bar}' + fd = open(fileName, 'rb') + RESPONSE += ( + f'The beginning of file: \'{escape_for_html(fileName)}\' is:\n\n' + f'{escape_for_html(fd.read(1000).decode('utf-8'))}' + ) + except IOError as e: + RESPONSE += ( + f'Problem reading from file \'{{escape_for_html(fileName)}}\': ' + f'{escape_for_html(e.strerror)}' + ) + finally: + try: + if fd is not None: + fd.close() + except IOError: + pass # "// we tried..." + + return RESPONSE + diff --git a/Samples/BenchmarkTest01117.py b/Samples/BenchmarkTest01117.py new file mode 100644 index 0000000..dc38b3d --- /dev/null +++ b/Samples/BenchmarkTest01117.py @@ -0,0 +1,64 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xpathi-02/BenchmarkTest01117', methods=['GET']) + def BenchmarkTest01117_get(): + return BenchmarkTest01117_post() + + @app.route('/benchmark/xpathi-02/BenchmarkTest01117', methods=['POST']) + def BenchmarkTest01117_post(): + RESPONSE = "" + + import helpers.separate_request + scr = helpers.separate_request.request_wrapper(request) + param = scr.get_safe_value("BenchmarkTest01117") + + map8971 = {} + map8971['keyA-8971'] = 'a-Value' + map8971['keyB-8971'] = param + map8971['keyC'] = 'another-Value' + bar = "safe!" + bar = map8971['keyB-8971'] + bar = map8971['keyA-8971'] + + import elementpath + import xml.etree.ElementTree as ET + import helpers.utils + + try: + root = ET.parse(f'{helpers.utils.RES_DIR}/employees.xml') + nodes = elementpath.select(root, f"/Employees/Employee[@emplid=\'{bar.replace('\'', ''')}\']") + node_strings = [] + for node in nodes: + node_strings.append(' '.join([e.text for e in node])) + + RESPONSE += ( + f'Your XPATH query results are:
[ {', '.join(node_strings)} ]' + ) + except: + RESPONSE += ( + f'Error parsing XPath Query: \'{escape_for_html(query)}\'' + ) + + + return RESPONSE + diff --git a/Samples/BenchmarkTest01126.py b/Samples/BenchmarkTest01126.py new file mode 100644 index 0000000..8f2e48c --- /dev/null +++ b/Samples/BenchmarkTest01126.py @@ -0,0 +1,64 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-03/BenchmarkTest01126', methods=['GET']) + def BenchmarkTest01126_get(): + return BenchmarkTest01126_post() + + @app.route('/benchmark/weakrand-03/BenchmarkTest01126', methods=['POST']) + def BenchmarkTest01126_post(): + RESPONSE = "" + + import helpers.separate_request + scr = helpers.separate_request.request_wrapper(request) + param = scr.get_safe_value("BenchmarkTest01126") + + bar = "alsosafe" + if param: + lst = [] + lst.append('safe') + lst.append(param) + lst.append('moresafe') + lst.pop(0) + bar = lst[1] + + import random + from helpers.utils import mysession + + num = 'BenchmarkTest01126'[13:] + user = f'Nancy{num}' + cookie = f'rememberMe{num}' + value = str(random.normalvariate())[2:] + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie: ' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest01131.py b/Samples/BenchmarkTest01131.py new file mode 100644 index 0000000..c3f1f19 --- /dev/null +++ b/Samples/BenchmarkTest01131.py @@ -0,0 +1,60 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-03/BenchmarkTest01131', methods=['GET']) + def BenchmarkTest01131_get(): + return BenchmarkTest01131_post() + + @app.route('/benchmark/weakrand-03/BenchmarkTest01131', methods=['POST']) + def BenchmarkTest01131_post(): + RESPONSE = "" + + import helpers.separate_request + scr = helpers.separate_request.request_wrapper(request) + param = scr.get_safe_value("BenchmarkTest01131") + + string37417 = 'help' + string37417 += param + string37417 += 'snapes on a plane' + bar = string37417[4:-17] + + import random + from helpers.utils import mysession + + num = 'BenchmarkTest01131'[13:] + user = f'Randall{num}' + cookie = f'rememberMe{num}' + value = str(random.random())[2:] + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie: ' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest01134.py b/Samples/BenchmarkTest01134.py new file mode 100644 index 0000000..d1646d0 --- /dev/null +++ b/Samples/BenchmarkTest01134.py @@ -0,0 +1,60 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-03/BenchmarkTest01134', methods=['GET']) + def BenchmarkTest01134_get(): + return BenchmarkTest01134_post() + + @app.route('/benchmark/weakrand-03/BenchmarkTest01134', methods=['POST']) + def BenchmarkTest01134_post(): + RESPONSE = "" + + import helpers.separate_request + scr = helpers.separate_request.request_wrapper(request) + param = scr.get_safe_value("BenchmarkTest01134") + + string43851 = 'help' + string43851 += param + string43851 += 'snapes on a plane' + bar = string43851[4:-17] + + import secrets + from helpers.utils import mysession + + num = 'BenchmarkTest01134'[13:] + user = f'SafeRobbie{num}' + cookie = f'rememberMe{num}' + value = str(secrets.randbelow(2**32)) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie:' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest01135.py b/Samples/BenchmarkTest01135.py new file mode 100644 index 0000000..d90fc24 --- /dev/null +++ b/Samples/BenchmarkTest01135.py @@ -0,0 +1,58 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-03/BenchmarkTest01135', methods=['GET']) + def BenchmarkTest01135_get(): + return BenchmarkTest01135_post() + + @app.route('/benchmark/weakrand-03/BenchmarkTest01135', methods=['POST']) + def BenchmarkTest01135_post(): + RESPONSE = "" + + import helpers.separate_request + scr = helpers.separate_request.request_wrapper(request) + param = scr.get_safe_value("BenchmarkTest01135") + + superstring = f'40994{param}abcd' + bar = superstring[len('40994'):len(superstring)-5] + + import secrets + from helpers.utils import mysession + + num = 'BenchmarkTest01135'[13:] + user = f'SafeRobbie{num}' + cookie = f'rememberMe{num}' + value = str(secrets.randbelow(2**32)) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie:' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest01141.py b/Samples/BenchmarkTest01141.py new file mode 100644 index 0000000..f075e2a --- /dev/null +++ b/Samples/BenchmarkTest01141.py @@ -0,0 +1,65 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-03/BenchmarkTest01141', methods=['GET']) + def BenchmarkTest01141_get(): + return BenchmarkTest01141_post() + + @app.route('/benchmark/weakrand-03/BenchmarkTest01141', methods=['POST']) + def BenchmarkTest01141_post(): + RESPONSE = "" + + import helpers.separate_request + scr = helpers.separate_request.request_wrapper(request) + param = scr.get_safe_value("BenchmarkTest01141") + + bar = "" + if param: + lst = [] + lst.append('safe') + lst.append(param) + lst.append('moresafe') + lst.pop(0) + bar = lst[0] + + import random + import base64 + from helpers.utils import mysession + + num = 'BenchmarkTest01141'[13:] + user = f'SafeBarbara{num}' + cookie = f'rememberMe{num}' + value = str(base64.b64encode(random.SystemRandom().randbytes(32))) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie: ' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest01150.py b/Samples/BenchmarkTest01150.py new file mode 100644 index 0000000..559d4ed --- /dev/null +++ b/Samples/BenchmarkTest01150.py @@ -0,0 +1,70 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/hash-01/BenchmarkTest01150', methods=['GET']) + def BenchmarkTest01150_get(): + return BenchmarkTest01150_post() + + @app.route('/benchmark/hash-01/BenchmarkTest01150', methods=['POST']) + def BenchmarkTest01150_post(): + RESPONSE = "" + + import helpers.separate_request + scr = helpers.separate_request.request_wrapper(request) + param = scr.get_safe_value("BenchmarkTest01150") + + map23948 = {} + map23948['keyA-23948'] = 'a-Value' + map23948['keyB-23948'] = param + map23948['keyC'] = 'another-Value' + bar = "safe!" + bar = map23948['keyB-23948'] + bar = map23948['keyA-23948'] + + import hashlib, base64 + import io, helpers.utils + + input = '' + if isinstance(bar, str): + input = bar.encode('utf-8') + elif isinstance(bar, io.IOBase): + input = bar.read(1000) + + if len(input) == 0: + RESPONSE += ( + 'Cannot generate hash: Input was empty.' + ) + return RESPONSE + + hash = hashlib.sha384() + hash.update(input) + + result = hash.digest() + f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + f.write(f'hash_value={base64.b64encode(result)}\n') + RESPONSE += ( + f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.' + ) + f.close() + + return RESPONSE + diff --git a/Samples/BenchmarkTest01162.py b/Samples/BenchmarkTest01162.py new file mode 100644 index 0000000..c746cc6 --- /dev/null +++ b/Samples/BenchmarkTest01162.py @@ -0,0 +1,47 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/trustbound-00/BenchmarkTest01162', methods=['GET']) + def BenchmarkTest01162_get(): + return BenchmarkTest01162_post() + + @app.route('/benchmark/trustbound-00/BenchmarkTest01162', methods=['POST']) + def BenchmarkTest01162_post(): + RESPONSE = "" + + import helpers.separate_request + scr = helpers.separate_request.request_wrapper(request) + param = scr.get_safe_value("BenchmarkTest01162") + + bar = param + + import flask + + flask.session[bar] = '12345' + + RESPONSE += ( + f'Item: \'{escape_for_html(bar)}' + '\' with value: 12345 saved in session.' + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest01170.py b/Samples/BenchmarkTest01170.py new file mode 100644 index 0000000..66e6660 --- /dev/null +++ b/Samples/BenchmarkTest01170.py @@ -0,0 +1,76 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/ldapi-00/BenchmarkTest01170', methods=['GET']) + def BenchmarkTest01170_get(): + return BenchmarkTest01170_post() + + @app.route('/benchmark/ldapi-00/BenchmarkTest01170', methods=['POST']) + def BenchmarkTest01170_post(): + RESPONSE = "" + + import helpers.separate_request + scr = helpers.separate_request.request_wrapper(request) + param = scr.get_safe_value("BenchmarkTest01170") + + possible = "ABC" + guess = possible[1] + + match guess: + case 'A': + bar = param + case 'B': + bar = 'bob' + case 'C' | 'D': + bar = param + case _: + bar = 'bob\'s your uncle' + + import helpers.ldap + import ldap3 + + base = 'ou=users,ou=system' + filter = f'(&(objectclass=person)(|(uid={bar})(street=The streetz 4 Ms bar)))' + try: + conn = helpers.ldap.get_connection() + conn.search(base, filter, attributes=ldap3.ALL_ATTRIBUTES) + found = False + for e in conn.entries: + RESPONSE += ( + f'LDAP query results:
' + f'Record found with name {e['uid']}
' + f'Address: {e['street']}
' + ) + found = True + conn.unbind() + + if not found: + RESPONSE += ( + f'LDAP query results: nothing found for query: {helpers.utils.escape_for_html(filter)}' + ) + except: + RESPONSE += ( + "Error processing LDAP query." + ) + + return RESPONSE + diff --git a/Samples/BenchmarkTest01181.py b/Samples/BenchmarkTest01181.py new file mode 100644 index 0000000..0f163f4 --- /dev/null +++ b/Samples/BenchmarkTest01181.py @@ -0,0 +1,47 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/pathtraver-01/BenchmarkTest01181', methods=['GET']) + def BenchmarkTest01181_get(): + return BenchmarkTest01181_post() + + @app.route('/benchmark/pathtraver-01/BenchmarkTest01181', methods=['POST']) + def BenchmarkTest01181_post(): + RESPONSE = "" + + param = request.form.get("BenchmarkTest01181") + if not param: + param = "" + + + import os + import helpers.utils + + fileName = f'{helpers.utils.TESTFILES_DIR}/{param}' + if os.path.exists(fileName): + RESPONSE += ( f"File \'{escape_for_html(fileName)}\' exists." ) + else: + RESPONSE += ( f"File \'{escape_for_html(fileName)}\' does not exist." ) + + return RESPONSE + + diff --git a/Samples/BenchmarkTest01183.py b/Samples/BenchmarkTest01183.py new file mode 100644 index 0000000..a7ccdf1 --- /dev/null +++ b/Samples/BenchmarkTest01183.py @@ -0,0 +1,57 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/pathtraver-02/BenchmarkTest01183', methods=['GET']) + def BenchmarkTest01183_get(): + return BenchmarkTest01183_post() + + @app.route('/benchmark/pathtraver-02/BenchmarkTest01183', methods=['POST']) + def BenchmarkTest01183_post(): + RESPONSE = "" + + values = request.form.getlist("BenchmarkTest01183") + param = "" + if values: + param = values[0] + + + import helpers.utils + + fileName = None + fd = None + + try: + fileName = f'{helpers.utils.TESTFILES_DIR}/{param}' + with open(fileName, 'rb') as fd: + RESPONSE += ( + f'The beginning of file: \'{escape_for_html(fileName)}\' is:\n\n' + f'{escape_for_html(fd.read(1000).decode('utf-8'))}' + ) + except IOError as e: + RESPONSE += ( + f'Problem reading from file \'{{escape_for_html(fileName)}}\': ' + f'{escape_for_html(e.strerror)}' + ) + + return RESPONSE + + diff --git a/Samples/BenchmarkTest01196.py b/Samples/BenchmarkTest01196.py new file mode 100644 index 0000000..cd5812e --- /dev/null +++ b/Samples/BenchmarkTest01196.py @@ -0,0 +1,52 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/pathtraver-02/BenchmarkTest01196', methods=['GET']) + def BenchmarkTest01196_get(): + return BenchmarkTest01196_post() + + @app.route('/benchmark/pathtraver-02/BenchmarkTest01196', methods=['POST']) + def BenchmarkTest01196_post(): + RESPONSE = "" + + param = request.headers.get("BenchmarkTest01196") + if not param: + param = "" + + + import helpers.utils + + try: + fileName = f'{helpers.utils.TESTFILES_DIR}/{param}' + with open(fileName, 'wb') as fd: + RESPONSE += ( + f'Now ready to write to file: {escape_for_html(fileName)}' + ) + except IOError as e: + RESPONSE += ( + f'Problem reading from file \'{escape_for_html(fileName)}\': ' + f'{escape_for_html(e.strerror)}' + ) + + return RESPONSE + + diff --git a/Samples/BenchmarkTest01198.py b/Samples/BenchmarkTest01198.py new file mode 100644 index 0000000..f04535e --- /dev/null +++ b/Samples/BenchmarkTest01198.py @@ -0,0 +1,66 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xpathi-02/BenchmarkTest01198', methods=['GET']) + def BenchmarkTest01198_get(): + return BenchmarkTest01198_post() + + @app.route('/benchmark/xpathi-02/BenchmarkTest01198', methods=['POST']) + def BenchmarkTest01198_post(): + RESPONSE = "" + + param = "" + headers = request.headers.getlist("BenchmarkTest01198") + + if headers: + param = headers[0] + + + import lxml.etree + import helpers.utils + + try: + if '\'' in param: + RESPONSE += ( + "Employee ID must not contain apostrophes" + ) + return RESPONSE + + fd = open(f'{helpers.utils.RES_DIR}/employees.xml', 'rb') + root = lxml.etree.parse(fd) + query = f'/Employees/Employee[@emplid=\'{param}\']' + nodes = root.xpath(query) + node_strings = [] + for node in nodes: + node_strings.append(' '.join([e.text for e in node])) + + RESPONSE += ( + f'Your XPATH query results are:
[ {', '.join(node_strings)} ]' + ) + except: + RESPONSE += ( + f'Error parsing XPath Query: \'{escape_for_html(query)}\'' + ) + + return RESPONSE + + diff --git a/Samples/BenchmarkTest01205.py b/Samples/BenchmarkTest01205.py new file mode 100644 index 0000000..e94f2e8 --- /dev/null +++ b/Samples/BenchmarkTest01205.py @@ -0,0 +1,57 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/weakrand-04/BenchmarkTest01205', methods=['GET']) + def BenchmarkTest01205_get(): + return BenchmarkTest01205_post() + + @app.route('/benchmark/weakrand-04/BenchmarkTest01205', methods=['POST']) + def BenchmarkTest01205_post(): + RESPONSE = "" + + param = request.args.get("BenchmarkTest01205") + if not param: + param = "" + + + import secrets + from helpers.utils import mysession + + num = 'BenchmarkTest01205'[13:] + user = f'SafeRobbie{num}' + cookie = f'rememberMe{num}' + value = str(secrets.randbelow(2**32)) + + if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]: + RESPONSE += ( + f'Welcome back: {user}
' + ) + else: + mysession[cookie] = value + RESPONSE += ( + f'{user} has been remembered with cookie:' + f'{cookie} whose value is: {mysession[cookie]}
' + ) + + return RESPONSE + + diff --git a/Samples/BenchmarkTest01206.py b/Samples/BenchmarkTest01206.py new file mode 100644 index 0000000..86cc541 --- /dev/null +++ b/Samples/BenchmarkTest01206.py @@ -0,0 +1,64 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/hash-01/BenchmarkTest01206', methods=['GET']) + def BenchmarkTest01206_get(): + return BenchmarkTest01206_post() + + @app.route('/benchmark/hash-01/BenchmarkTest01206', methods=['POST']) + def BenchmarkTest01206_post(): + RESPONSE = "" + + param = request.args.get("BenchmarkTest01206") + if not param: + param = "" + + + import hashlib, base64 + import io, helpers.utils + + input = '' + if isinstance(param, str): + input = param.encode('utf-8') + elif isinstance(param, io.IOBase): + input = param.read(1000) + + if len(input) == 0: + RESPONSE += ( + 'Cannot generate hash: Input was empty.' + ) + return RESPONSE + + hash = hashlib.sha384() + hash.update(input) + + result = hash.digest() + f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + f.write(f'hash_value={base64.b64encode(result)}\n') + RESPONSE += ( + f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.' + ) + f.close() + + return RESPONSE + + diff --git a/Samples/BenchmarkTest01207.py b/Samples/BenchmarkTest01207.py new file mode 100644 index 0000000..38f0aaf --- /dev/null +++ b/Samples/BenchmarkTest01207.py @@ -0,0 +1,61 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/securecookie-00/BenchmarkTest01207', methods=['GET']) + def BenchmarkTest01207_get(): + return BenchmarkTest01207_post() + + @app.route('/benchmark/securecookie-00/BenchmarkTest01207', methods=['POST']) + def BenchmarkTest01207_post(): + RESPONSE = "" + + param = request.args.get("BenchmarkTest01207") + if not param: + param = "" + + + from flask import make_response + import io + import helpers.utils + + input = '' + if isinstance(param, str): + input = param.encode('utf-8') + elif isinstance(param, io.IOBase): + input = param.read(1000) + + cookie = 'SomeCookie' + value = input.decode('utf-8') + + RESPONSE += ( + f'Created cookie: \'{cookie}\' with value \'{helpers.utils.escape_for_html(value)}\' and secure flag set to false.' + ) + + RESPONSE = make_response(RESPONSE) + RESPONSE.set_cookie(cookie, value, + path=request.path, + secure=True, + httponly=True) + + return RESPONSE + + diff --git a/Samples/BenchmarkTest01210.py b/Samples/BenchmarkTest01210.py new file mode 100644 index 0000000..ab13fc6 --- /dev/null +++ b/Samples/BenchmarkTest01210.py @@ -0,0 +1,45 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/xss-01/BenchmarkTest01210', methods=['GET']) + def BenchmarkTest01210_get(): + return BenchmarkTest01210_post() + + @app.route('/benchmark/xss-01/BenchmarkTest01210', methods=['POST']) + def BenchmarkTest01210_post(): + RESPONSE = "" + + values = request.args.getlist("BenchmarkTest01210") + param = "" + if values: + param = values[0] + + + + otherarg = "static text" + RESPONSE += ( + f'param is \'{param}\' and otherarg is \'{otherarg}\'' + ) + + return RESPONSE + + diff --git a/Samples/BenchmarkTest01221.py b/Samples/BenchmarkTest01221.py new file mode 100644 index 0000000..6ee0be4 --- /dev/null +++ b/Samples/BenchmarkTest01221.py @@ -0,0 +1,69 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/pathtraver-02/BenchmarkTest01221', methods=['GET']) + def BenchmarkTest01221_get(): + return BenchmarkTest01221_post() + + @app.route('/benchmark/pathtraver-02/BenchmarkTest01221', methods=['POST']) + def BenchmarkTest01221_post(): + RESPONSE = "" + + parts = request.path.split("/") + param = parts[1] + if not param: + param = "" + + + import helpers.utils + + fileName = None + fd = None + + if '../' in param: + RESPONSE += ( + 'File name must not include \'../\'' + ) + return RESPONSE + + try: + fileName = f'{helpers.utils.TESTFILES_DIR}/{param}' + fd = open(fileName, 'rb') + RESPONSE += ( + f'The beginning of file: \'{escape_for_html(fileName)}\' is:\n\n' + f'{escape_for_html(fd.read(1000).decode('utf-8'))}' + ) + except IOError as e: + RESPONSE += ( + f'Problem reading from file \'{{escape_for_html(fileName)}}\': ' + f'{escape_for_html(e.strerror)}' + ) + finally: + try: + if fd is not None: + fd.close() + except IOError: + pass # "// we tried..." + + return RESPONSE + + diff --git a/Samples/BenchmarkTest01222.py b/Samples/BenchmarkTest01222.py new file mode 100644 index 0000000..f956be4 --- /dev/null +++ b/Samples/BenchmarkTest01222.py @@ -0,0 +1,59 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/pathtraver-02/BenchmarkTest01222', methods=['GET']) + def BenchmarkTest01222_get(): + return BenchmarkTest01222_post() + + @app.route('/benchmark/pathtraver-02/BenchmarkTest01222', methods=['POST']) + def BenchmarkTest01222_post(): + RESPONSE = "" + + parts = request.path.split("/") + param = parts[1] + if not param: + param = "" + + + import helpers.utils + + try: + fileName = f'{helpers.utils.TESTFILES_DIR}/{param}' + fd = open(fileName, 'wb') + RESPONSE += ( + f'Now ready to write to file: {escape_for_html(fileName)}' + ) + except IOError as e: + RESPONSE += ( + f'Problem reading from file \'{escape_for_html(fileName)}\': ' + f'{escape_for_html(e.strerror)}' + ) + finally: + try: + if fd is not None: + fd.close() + except IOError: + pass # "// we tried..." + + return RESPONSE + + diff --git a/Samples/BenchmarkTest01227.py b/Samples/BenchmarkTest01227.py new file mode 100644 index 0000000..0d5cc9f --- /dev/null +++ b/Samples/BenchmarkTest01227.py @@ -0,0 +1,65 @@ +''' +OWASP Benchmark for Python v0.1 + +This file is part of the Open Web Application Security Project (OWASP) Benchmark Project. +For details, please see https://owasp.org/www-project-benchmark. + +The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms +of the GNU General Public License as published by the Free Software Foundation, version 3. + +The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + + Author: Theo Cartsonis + Created: 2025 +''' + +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @app.route('/benchmark/hash-01/BenchmarkTest01227', methods=['GET']) + def BenchmarkTest01227_get(): + return BenchmarkTest01227_post() + + @app.route('/benchmark/hash-01/BenchmarkTest01227', methods=['POST']) + def BenchmarkTest01227_post(): + RESPONSE = "" + + parts = request.path.split("/") + param = parts[1] + if not param: + param = "" + + + import hashlib, base64 + import io, helpers.utils + + input = '' + if isinstance(param, str): + input = param.encode('utf-8') + elif isinstance(param, io.IOBase): + input = param.read(1000) + + if len(input) == 0: + RESPONSE += ( + 'Cannot generate hash: Input was empty.' + ) + return RESPONSE + + hash = hashlib.new('md5') + hash.update(input) + + result = hash.digest() + f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + f.write(f'hash_value={base64.b64encode(result)}\n') + RESPONSE += ( + f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.' + ) + f.close() + + return RESPONSE + + diff --git a/Samples_Obfuscated/BenchmarkTest00002.py b/Samples_Obfuscated/BenchmarkTest00002.py new file mode 100644 index 0000000..41c1686 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00002.py @@ -0,0 +1,29 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_6.route('/benchmark/pathtraver-00/BenchmarkTest00002', methods=['GET']) + def BenchmarkTest00002_get(): + var_1 = var_2(var_3('web/pathtraver-00/BenchmarkTest00002.html')) + var_1.set_cookie('BenchmarkTest00002', 'Filename', max_age=60 * 3, secure=True, path=var_4.path, domain='localhost') + return var_1 + return var_5() + + @var_6.route('/benchmark/pathtraver-00/BenchmarkTest00002', methods=['POST']) + def BenchmarkTest00002_post(): + var_7 = '' + import urllib.parse + var_8 = var_9.parse.unquote_plus(var_4.cookies.get('BenchmarkTest00002', 'noCookieValueSupplied')) + var_10 = 'This should never happen' + if 'should' in var_10: + var_10 = var_8 + import codecs + import helpers.utils + try: + var_11 = var_12.open(f'{var_13.utils.TESTFILES_DIR}/{var_10}', 'r', 'utf-8') + var_7 += f"Access to file: '{var_14(var_11.name)}' created." + var_7 += ' And file already exists.' + except FileNotFoundError: + var_7 += " But file doesn't exist yet." + return var_7 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00007.py b/Samples_Obfuscated/BenchmarkTest00007.py new file mode 100644 index 0000000..da351ae --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00007.py @@ -0,0 +1,38 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_6.route('/benchmark/pathtraver-00/BenchmarkTest00007', methods=['GET']) + def BenchmarkTest00007_get(): + var_1 = var_2(var_3('web/pathtraver-00/BenchmarkTest00007.html')) + var_1.set_cookie('BenchmarkTest00007', 'FileName', max_age=60 * 3, secure=True, path=var_4.path, domain='localhost') + return var_1 + return var_5() + + @var_6.route('/benchmark/pathtraver-00/BenchmarkTest00007', methods=['POST']) + def BenchmarkTest00007_post(): + var_7 = '' + import urllib.parse + var_8 = var_9.parse.unquote_plus(var_4.cookies.get('BenchmarkTest00007', 'noCookieValueSupplied')) + var_10 = 'help' + var_10 += var_8 + var_10 += 'snapes on a plane' + var_11 = var_10[4:-17] + import helpers.utils + if '../' in var_11: + var_7 += "File name must not contain '../'" + return var_7 + try: + var_12 = f'{var_13.utils.TESTFILES_DIR}/{var_11}' + var_14 = open(var_12, 'wb') + var_7 += f'Now ready to write to file: {var_15(var_12)}' + except IOError as e: + var_7 += f"Problem reading from file '{var_15(var_12)}': {var_15(var_16.strerror)}" + finally: + try: + if var_14 is not None: + var_14.close() + except IOError: + pass + return var_7 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00014.py b/Samples_Obfuscated/BenchmarkTest00014.py new file mode 100644 index 0000000..e4b0c0e --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00014.py @@ -0,0 +1,37 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_6.route('/benchmark/xpathi-00/BenchmarkTest00014', methods=['GET']) + def BenchmarkTest00014_get(): + var_1 = var_2(var_3('web/xpathi-00/BenchmarkTest00014.html')) + var_1.set_cookie('BenchmarkTest00014', '2222', max_age=60 * 3, secure=True, path=var_4.path, domain='localhost') + return var_1 + return var_5() + + @var_6.route('/benchmark/xpathi-00/BenchmarkTest00014', methods=['POST']) + def BenchmarkTest00014_post(): + var_7 = '' + import urllib.parse + var_8 = var_9.parse.unquote_plus(var_4.cookies.get('BenchmarkTest00014', 'noCookieValueSupplied')) + import base64 + var_10 = var_11.b64encode(var_8.encode('utf-8')) + var_12 = var_11.b64decode(var_10).decode('utf-8') + import elementpath + import xml.etree.ElementTree as ET + import helpers.utils + if "'" in var_12: + var_7 += 'Employee ID must not contain apostrophes' + return var_7 + try: + var_13 = var_14.parse(f'{var_15.utils.RES_DIR}/employees.xml') + var_16 = f"/Employees/Employee[@emplid='{var_12}']" + var_17 = var_18.select(var_13, var_16) + var_19 = [] + for var_20 in var_17: + var_19.append(' '.join([var_21.text for var_21 in var_20])) + var_7 += f"Your XPATH query results are:
[ {', '.join(var_19)} ]" + except: + var_7 += f"Error parsing XPath Query: '{var_22(var_16)}'" + return var_7 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00015.py b/Samples_Obfuscated/BenchmarkTest00015.py new file mode 100644 index 0000000..383b580 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00015.py @@ -0,0 +1,37 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_6.route('/benchmark/xpathi-00/BenchmarkTest00015', methods=['GET']) + def BenchmarkTest00015_get(): + var_1 = var_2(var_3('web/xpathi-00/BenchmarkTest00015.html')) + var_1.set_cookie('BenchmarkTest00015', '2222', max_age=60 * 3, secure=True, path=var_4.path, domain='localhost') + return var_1 + return var_5() + + @var_6.route('/benchmark/xpathi-00/BenchmarkTest00015', methods=['POST']) + def BenchmarkTest00015_post(): + var_7 = '' + import urllib.parse + var_8 = var_9.parse.unquote_plus(var_4.cookies.get('BenchmarkTest00015', 'noCookieValueSupplied')) + var_10 = 'This should never happen' + if 'should' in var_10: + var_10 = var_8 + import elementpath + import xml.etree.ElementTree as ET + import helpers.utils + if "'" in var_10: + var_7 += 'Employee ID must not contain apostrophes' + return var_7 + try: + var_11 = var_12.parse(f'{var_13.utils.RES_DIR}/employees.xml') + var_14 = f"/Employees/Employee[@emplid='{var_10}']" + var_15 = var_16.select(var_11, var_14) + var_17 = [] + for var_18 in var_15: + var_17.append(' '.join([var_19.text for var_19 in var_18])) + var_7 += f"Your XPATH query results are:
[ {', '.join(var_17)} ]" + except: + var_7 += f"Error parsing XPath Query: '{var_20(var_14)}'" + return var_7 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00024.py b/Samples_Obfuscated/BenchmarkTest00024.py new file mode 100644 index 0000000..db3720c --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00024.py @@ -0,0 +1,43 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_6.route('/benchmark/xpathi-00/BenchmarkTest00024', methods=['GET']) + def BenchmarkTest00024_get(): + var_1 = var_2(var_3('web/xpathi-00/BenchmarkTest00024.html')) + var_1.set_cookie('BenchmarkTest00024', '2222', max_age=60 * 3, secure=True, path=var_4.path, domain='localhost') + return var_1 + return var_5() + + @var_6.route('/benchmark/xpathi-00/BenchmarkTest00024', methods=['POST']) + def BenchmarkTest00024_post(): + var_7 = '' + import urllib.parse + var_8 = var_9.parse.unquote_plus(var_4.cookies.get('BenchmarkTest00024', 'noCookieValueSupplied')) + import configparser + var_10 = 'safe!' + var_11 = var_12.ConfigParser() + var_11.add_section('section57764') + var_11.set('section57764', 'keyA-57764', 'a_Value') + var_11.set('section57764', 'keyB-57764', var_8) + var_10 = var_11.get('section57764', 'keyA-57764') + import lxml.etree + import helpers.utils + import io + try: + var_13 = open(f'{var_14.utils.RES_DIR}/employees.xml', 'rb') + var_15 = var_16.etree.parse(var_13) + var_17 = var_18.StringIO() + var_17.write("/Employees/Employee[@emplid='") + var_17.write(var_10) + var_17.write("']") + var_19 = var_17.getvalue() + var_20 = var_15.xpath(var_19) + var_21 = [] + for var_22 in var_20: + var_21.append(' '.join([var_23.text for var_23 in var_22])) + var_7 += f"Your XPATH query results are:
[ {', '.join(var_21)} ]" + except: + var_7 += f"Error parsing XPath Query: '{var_24(var_19)}'" + return var_7 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00040.py b/Samples_Obfuscated/BenchmarkTest00040.py new file mode 100644 index 0000000..c49e768 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00040.py @@ -0,0 +1,34 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_6.route('/benchmark/weakrand-00/BenchmarkTest00040', methods=['GET']) + def BenchmarkTest00040_get(): + var_1 = var_2(var_3('web/weakrand-00/BenchmarkTest00040.html')) + var_1.set_cookie('BenchmarkTest00040', 'whatever', max_age=60 * 3, secure=True, path=var_4.path, domain='localhost') + return var_1 + return var_5() + + @var_6.route('/benchmark/weakrand-00/BenchmarkTest00040', methods=['POST']) + def BenchmarkTest00040_post(): + var_7 = '' + import urllib.parse + var_8 = var_9.parse.unquote_plus(var_4.cookies.get('BenchmarkTest00040', 'noCookieValueSupplied')) + var_10 = 'help' + var_10 += var_8 + var_10 += 'snapes on a plane' + var_11 = var_10[4:-17] + import base64 + import secrets + from helpers.utils import mysession + var_12 = 'BenchmarkTest00040'[13:] + var_13 = f'SafeToby{var_12}' + var_14 = f'rememberMe{var_12}' + var_15 = var_16.b64encode(var_17.token_bytes(32)) + if var_14 in var_18 and var_4.cookies.get(var_14) == var_18[var_14]: + var_7 += f'Welcome back: {var_13}
' + else: + var_18[var_14] = var_15 + var_7 += f'{var_13} has been remembered with cookie:{var_14} whose value is: {var_18[var_14]}
' + return var_7 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00044.py b/Samples_Obfuscated/BenchmarkTest00044.py new file mode 100644 index 0000000..c2d1ada --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00044.py @@ -0,0 +1,32 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_6.route('/benchmark/weakrand-00/BenchmarkTest00044', methods=['GET']) + def BenchmarkTest00044_get(): + var_1 = var_2(var_3('web/weakrand-00/BenchmarkTest00044.html')) + var_1.set_cookie('BenchmarkTest00044', 'whatever', max_age=60 * 3, secure=True, path=var_4.path, domain='localhost') + return var_1 + return var_5() + + @var_6.route('/benchmark/weakrand-00/BenchmarkTest00044', methods=['POST']) + def BenchmarkTest00044_post(): + var_7 = '' + import urllib.parse + var_8 = var_9.parse.unquote_plus(var_4.cookies.get('BenchmarkTest00044', 'noCookieValueSupplied')) + import base64 + var_10 = var_11.b64encode(var_8.encode('utf-8')) + var_12 = var_11.b64decode(var_10).decode('utf-8') + import random + from helpers.utils import mysession + var_13 = 'BenchmarkTest00044'[13:] + var_14 = f'SafeRandy{var_13}' + var_15 = f'rememberMe{var_13}' + var_16 = str(var_17.SystemRandom().getrandbits(32)) + if var_15 in var_18 and var_4.cookies.get(var_15) == var_18[var_15]: + var_7 += f'Welcome back: {var_14}
' + else: + var_18[var_15] = var_16 + var_7 += f'{var_14} has been remembered with cookie: {var_15} whose value is: {var_18[var_15]}
' + return var_7 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00052.py b/Samples_Obfuscated/BenchmarkTest00052.py new file mode 100644 index 0000000..02d2aa4 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00052.py @@ -0,0 +1,37 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_6.route('/benchmark/weakrand-00/BenchmarkTest00052', methods=['GET']) + def BenchmarkTest00052_get(): + var_1 = var_2(var_3('web/weakrand-00/BenchmarkTest00052.html')) + var_1.set_cookie('BenchmarkTest00052', 'whatever', max_age=60 * 3, secure=True, path=var_4.path, domain='localhost') + return var_1 + return var_5() + + @var_6.route('/benchmark/weakrand-00/BenchmarkTest00052', methods=['POST']) + def BenchmarkTest00052_post(): + var_7 = '' + import urllib.parse + var_8 = var_9.parse.unquote_plus(var_4.cookies.get('BenchmarkTest00052', 'noCookieValueSupplied')) + var_10 = '' + if var_8: + var_11 = [] + var_11.append('safe') + var_11.append(var_8) + var_11.append('moresafe') + var_11.pop(0) + var_10 = var_11[0] + import random + from helpers.utils import mysession + var_12 = 'BenchmarkTest00052'[13:] + var_13 = f'SafeRandall{var_12}' + var_14 = f'rememberMe{var_12}' + var_15 = str(var_16.SystemRandom().random())[2:] + if var_14 in var_17 and var_4.cookies.get(var_14) == var_17[var_14]: + var_7 += f'Welcome back: {var_13}
' + else: + var_17[var_14] = var_15 + var_7 += f'{var_13} has been remembered with cookie: {var_14} whose value is: {var_17[var_14]}
' + return var_7 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00055.py b/Samples_Obfuscated/BenchmarkTest00055.py new file mode 100644 index 0000000..d34e874 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00055.py @@ -0,0 +1,37 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_6.route('/benchmark/hash-00/BenchmarkTest00055', methods=['GET']) + def BenchmarkTest00055_get(): + var_1 = var_2(var_3('web/hash-00/BenchmarkTest00055.html')) + var_1.set_cookie('BenchmarkTest00055', 'someSecret', max_age=60 * 3, secure=True, path=var_4.path, domain='localhost') + return var_1 + return var_5() + + @var_6.route('/benchmark/hash-00/BenchmarkTest00055', methods=['POST']) + def BenchmarkTest00055_post(): + var_7 = '' + import urllib.parse + var_8 = var_9.parse.unquote_plus(var_4.cookies.get('BenchmarkTest00055', 'noCookieValueSupplied')) + var_10 = 106 + var_11 = 'This should never happen' if 7 * 42 - var_10 > 200 else var_8 + import hashlib, base64 + import io, helpers.utils + input = '' + if isinstance(var_11, str): + input = var_11.encode('utf-8') + elif isinstance(var_11, var_12.IOBase): + input = var_11.read(1000) + if len(input) == 0: + var_7 += 'Cannot generate hash: Input was empty.' + return var_7 + hash = var_13.new('sha384') + hash.update(input) + var_14 = hash.digest() + var_15 = open(f'{var_16.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + var_15.write(f'hash_value={var_17.b64encode(var_14)}\n') + var_7 += f"Sensitive value '{var_16.utils.escape_for_html(input.decode('utf-8'))}' hashed and stored." + var_15.close() + return var_7 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00062.py b/Samples_Obfuscated/BenchmarkTest00062.py new file mode 100644 index 0000000..6e06605 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00062.py @@ -0,0 +1,40 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_6.route('/benchmark/hash-00/BenchmarkTest00062', methods=['GET']) + def BenchmarkTest00062_get(): + var_1 = var_2(var_3('web/hash-00/BenchmarkTest00062.html')) + var_1.set_cookie('BenchmarkTest00062', 'someSecret', max_age=60 * 3, secure=True, path=var_4.path, domain='localhost') + return var_1 + return var_5() + + @var_6.route('/benchmark/hash-00/BenchmarkTest00062', methods=['POST']) + def BenchmarkTest00062_post(): + var_7 = '' + import urllib.parse + var_8 = var_9.parse.unquote_plus(var_4.cookies.get('BenchmarkTest00062', 'noCookieValueSupplied')) + var_10 = 'This should never happen' + if 'should' not in var_10: + var_11 = 'Ifnot case passed' + else: + var_11 = var_8 + import hashlib, base64 + import io, helpers.utils + input = '' + if isinstance(var_11, str): + input = var_11.encode('utf-8') + elif isinstance(var_11, var_12.IOBase): + input = var_11.read(1000) + if len(input) == 0: + var_7 += 'Cannot generate hash: Input was empty.' + return var_7 + hash = var_13.sha512() + hash.update(input) + var_14 = hash.digest() + var_15 = open(f'{var_16.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + var_15.write(f'hash_value={var_17.b64encode(var_14)}\n') + var_7 += f"Sensitive value '{var_16.utils.escape_for_html(input.decode('utf-8'))}' hashed and stored." + var_15.close() + return var_7 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00065.py b/Samples_Obfuscated/BenchmarkTest00065.py new file mode 100644 index 0000000..ae68249 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00065.py @@ -0,0 +1,33 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_6.route('/benchmark/securecookie-00/BenchmarkTest00065', methods=['GET']) + def BenchmarkTest00065_get(): + var_1 = var_2(var_3('web/securecookie-00/BenchmarkTest00065.html')) + var_1.set_cookie('BenchmarkTest00065', 'whatever', max_age=60 * 3, secure=True, path=var_4.path, domain='localhost') + return var_1 + return var_5() + + @var_6.route('/benchmark/securecookie-00/BenchmarkTest00065', methods=['POST']) + def BenchmarkTest00065_post(): + var_7 = '' + import urllib.parse + var_8 = var_9.parse.unquote_plus(var_4.cookies.get('BenchmarkTest00065', 'noCookieValueSupplied')) + import html + var_10 = var_11.escape(var_8) + from flask import make_response + import io + import helpers.utils + input = '' + if isinstance(var_10, str): + input = var_10.encode('utf-8') + elif isinstance(var_10, var_12.IOBase): + input = var_10.read(1000) + var_13 = 'SomeCookie' + var_14 = input.decode('utf-8') + var_7 += f"Created cookie: '{var_13}' with value '{var_15.utils.escape_for_html(var_14)}' and secure flag set to false." + var_7 = var_2(var_7) + var_7.set_cookie(var_13, var_14, path=var_4.path, secure=False, httponly=True) + return var_7 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00066.py b/Samples_Obfuscated/BenchmarkTest00066.py new file mode 100644 index 0000000..9078d8d --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00066.py @@ -0,0 +1,34 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_6.route('/benchmark/securecookie-00/BenchmarkTest00066', methods=['GET']) + def BenchmarkTest00066_get(): + var_1 = var_2(var_3('web/securecookie-00/BenchmarkTest00066.html')) + var_1.set_cookie('BenchmarkTest00066', 'whatever', max_age=60 * 3, secure=True, path=var_4.path, domain='localhost') + return var_1 + return var_5() + + @var_6.route('/benchmark/securecookie-00/BenchmarkTest00066', methods=['POST']) + def BenchmarkTest00066_post(): + var_7 = '' + import urllib.parse + var_8 = var_9.parse.unquote_plus(var_4.cookies.get('BenchmarkTest00066', 'noCookieValueSupplied')) + var_10 = 'This should never happen' + if 'should' in var_10: + var_10 = var_8 + from flask import make_response + import io + import helpers.utils + input = '' + if isinstance(var_10, str): + input = var_10.encode('utf-8') + elif isinstance(var_10, var_11.IOBase): + input = var_10.read(1000) + var_12 = 'SomeCookie' + var_13 = input.decode('utf-8') + var_7 += f"Created cookie: '{var_12}' with value '{var_14.utils.escape_for_html(var_13)}' and secure flag set to false." + var_7 = var_2(var_7) + var_7.set_cookie(var_12, var_13, path=var_4.path, secure=False, httponly=True) + return var_7 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00089.py b/Samples_Obfuscated/BenchmarkTest00089.py new file mode 100644 index 0000000..b3a08de --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00089.py @@ -0,0 +1,29 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/pathtraver-00/BenchmarkTest00089', methods=['GET']) + def BenchmarkTest00089_get(): + return var_1() + + @var_2.route('/benchmark/pathtraver-00/BenchmarkTest00089', methods=['POST']) + def BenchmarkTest00089_post(): + var_3 = '' + var_4 = var_5.form.get('BenchmarkTest00089') + if not var_4: + var_4 = '' + var_6 = {} + var_6['keyA-83150'] = 'a-Value' + var_6['keyB-83150'] = var_4 + var_6['keyC'] = 'another-Value' + var_7 = var_6['keyB-83150'] + import pathlib + import helpers.utils + var_8 = var_9.Path(var_10.utils.TESTFILES_DIR) + var_11 = var_8 / var_7 + if var_11.exists(): + var_3 += f"File '{var_12(str(var_11))}' exists." + else: + var_3 += f"File '{var_12(str(var_11))}' does not exist." + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00094.py b/Samples_Obfuscated/BenchmarkTest00094.py new file mode 100644 index 0000000..51739ea --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00094.py @@ -0,0 +1,29 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/pathtraver-00/BenchmarkTest00094', methods=['GET']) + def BenchmarkTest00094_get(): + return var_1() + + @var_2.route('/benchmark/pathtraver-00/BenchmarkTest00094', methods=['POST']) + def BenchmarkTest00094_post(): + var_3 = '' + var_4 = var_5.form.get('BenchmarkTest00094') + if not var_4: + var_4 = '' + var_6 = 106 + var_7 = 'This_should_always_happen' if 7 * 18 + var_6 > 200 else var_4 + import pathlib + import helpers.utils + try: + var_8 = var_9.Path(var_10.utils.TESTFILES_DIR) + var_11 = (var_8 / var_7).resolve() + if not str(var_11).startswith(str(var_8)): + var_3 += 'Invalid Path.' + return var_3 + var_3 += f"The beginning of file: '{var_12(str(var_11))}' is:\n\n{var_12(var_11.read_text()[:1000])}" + except OSError: + var_3 += f"Problem reading from file '{{escape_for_html(fileName)}}': {var_12(var_13.strerror)}" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00097.py b/Samples_Obfuscated/BenchmarkTest00097.py new file mode 100644 index 0000000..2b9ac3d --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00097.py @@ -0,0 +1,21 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xss-00/BenchmarkTest00097', methods=['GET']) + def BenchmarkTest00097_get(): + return var_1() + + @var_2.route('/benchmark/xss-00/BenchmarkTest00097', methods=['POST']) + def BenchmarkTest00097_post(): + var_3 = '' + var_4 = var_5.form.get('BenchmarkTest00097') + if not var_4: + var_4 = '' + var_6 = '' + if var_4: + var_6 = var_4.split(' ')[0] + var_7 = 'static text' + var_3 += f"bar is '{var_6}' and otherarg is '{var_7}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00111.py b/Samples_Obfuscated/BenchmarkTest00111.py new file mode 100644 index 0000000..0e8ec8e --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00111.py @@ -0,0 +1,32 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xpathi-00/BenchmarkTest00111', methods=['GET']) + def BenchmarkTest00111_get(): + return var_1() + + @var_2.route('/benchmark/xpathi-00/BenchmarkTest00111', methods=['POST']) + def BenchmarkTest00111_post(): + var_3 = '' + var_4 = var_5.form.get('BenchmarkTest00111') + if not var_4: + var_4 = '' + var_6 = 'This should never happen' + if 'should' in var_6: + var_6 = var_4 + import lxml.etree + import helpers.utils + try: + var_7 = open(f'{var_8.utils.RES_DIR}/employees.xml', 'rb') + var_9 = var_10.etree.parse(var_7) + var_11 = f'/Employees/Employee[@emplid=$name]' + var_12 = var_9.xpath(var_11, name=var_6) + var_13 = [] + for var_14 in var_12: + var_13.append(' '.join([var_15.text for var_15 in var_14])) + var_3 += f"Your XPATH query results are:
[ {', '.join(var_13)} ]" + except: + var_3 += f"Error parsing XPath Query: '{var_16(var_11)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00115.py b/Samples_Obfuscated/BenchmarkTest00115.py new file mode 100644 index 0000000..a53bf34 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00115.py @@ -0,0 +1,30 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-00/BenchmarkTest00115', methods=['GET']) + def BenchmarkTest00115_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-00/BenchmarkTest00115', methods=['POST']) + def BenchmarkTest00115_post(): + var_3 = '' + var_4 = var_5.form.get('BenchmarkTest00115') + if not var_4: + var_4 = '' + var_6 = '' + if var_4: + var_6 = var_4.split(' ')[0] + import random + from helpers.utils import mysession + var_7 = 'BenchmarkTest00115'[13:] + var_8 = f'Randy{var_7}' + var_9 = f'rememberMe{var_7}' + var_10 = str(var_11.getrandbits(32)) + if var_9 in var_12 and var_5.cookies.get(var_9) == var_12[var_9]: + var_3 += f'Welcome back: {var_8}
' + else: + var_12[var_9] = var_10 + var_3 += f'{var_8} has been remembered with cookie: {var_9} whose value is: {var_12[var_9]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00119.py b/Samples_Obfuscated/BenchmarkTest00119.py new file mode 100644 index 0000000..5365f0e --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00119.py @@ -0,0 +1,38 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-00/BenchmarkTest00119', methods=['GET']) + def BenchmarkTest00119_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-00/BenchmarkTest00119', methods=['POST']) + def BenchmarkTest00119_post(): + var_3 = '' + var_4 = var_5.form.get('BenchmarkTest00119') + if not var_4: + var_4 = '' + var_6 = 'ABC' + var_7 = var_6[1] + match var_7: + case 'A': + var_8 = var_4 + case 'B': + var_8 = 'bob' + case 'C' | 'D': + var_8 = var_4 + case _: + var_8 = "bob's your uncle" + import secrets + from helpers.utils import mysession + var_9 = 'BenchmarkTest00119'[13:] + var_10 = f'SafeRobbie{var_9}' + var_11 = f'rememberMe{var_9}' + var_12 = str(var_13.randbelow(2 ** 32)) + if var_11 in var_14 and var_5.cookies.get(var_11) == var_14[var_11]: + var_3 += f'Welcome back: {var_10}
' + else: + var_14[var_11] = var_12 + var_3 += f'{var_10} has been remembered with cookie:{var_11} whose value is: {var_14[var_11]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00121.py b/Samples_Obfuscated/BenchmarkTest00121.py new file mode 100644 index 0000000..0fd271b --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00121.py @@ -0,0 +1,35 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-00/BenchmarkTest00121', methods=['GET']) + def BenchmarkTest00121_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-00/BenchmarkTest00121', methods=['POST']) + def BenchmarkTest00121_post(): + var_3 = '' + var_4 = var_5.form.get('BenchmarkTest00121') + if not var_4: + var_4 = '' + import configparser + var_6 = 'safe!' + var_7 = var_8.ConfigParser() + var_7.add_section('section68097') + var_7.set('section68097', 'keyA-68097', 'a-Value') + var_7.set('section68097', 'keyB-68097', var_4) + var_6 = var_7.get('section68097', 'keyB-68097') + import base64 + import secrets + from helpers.utils import mysession + var_9 = 'BenchmarkTest00121'[13:] + var_10 = f'SafeToby{var_9}' + var_11 = f'rememberMe{var_9}' + var_12 = var_13.b64encode(var_14.token_bytes(32)) + if var_11 in var_15 and var_5.cookies.get(var_11) == var_15[var_11]: + var_3 += f'Welcome back: {var_10}
' + else: + var_15[var_11] = var_12 + var_3 += f'{var_10} has been remembered with cookie:{var_11} whose value is: {var_15[var_11]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00125.py b/Samples_Obfuscated/BenchmarkTest00125.py new file mode 100644 index 0000000..6cf04ea --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00125.py @@ -0,0 +1,30 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-00/BenchmarkTest00125', methods=['GET']) + def BenchmarkTest00125_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-00/BenchmarkTest00125', methods=['POST']) + def BenchmarkTest00125_post(): + var_3 = '' + var_4 = var_5.form.get('BenchmarkTest00125') + if not var_4: + var_4 = '' + var_6 = f'94919{var_4}abcd' + var_7 = var_6[len('94919'):len(var_6) - 5] + import base64 + import secrets + from helpers.utils import mysession + var_8 = 'BenchmarkTest00125'[13:] + var_9 = f'SafeToby{var_8}' + var_10 = f'rememberMe{var_8}' + var_11 = var_12.b64encode(var_13.token_bytes(32)) + if var_10 in var_14 and var_5.cookies.get(var_10) == var_14[var_10]: + var_3 += f'Welcome back: {var_9}
' + else: + var_14[var_10] = var_11 + var_3 += f'{var_9} has been remembered with cookie:{var_10} whose value is: {var_14[var_10]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00131.py b/Samples_Obfuscated/BenchmarkTest00131.py new file mode 100644 index 0000000..f05811b --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00131.py @@ -0,0 +1,28 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-00/BenchmarkTest00131', methods=['GET']) + def BenchmarkTest00131_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-00/BenchmarkTest00131', methods=['POST']) + def BenchmarkTest00131_post(): + var_3 = '' + var_4 = var_5.form.get('BenchmarkTest00131') + if not var_4: + var_4 = '' + var_6 = var_4 + '_SafeStuff' + import random + from helpers.utils import mysession + var_7 = 'BenchmarkTest00131'[13:] + var_8 = f'SafeRandy{var_7}' + var_9 = f'rememberMe{var_7}' + var_10 = str(var_11.SystemRandom().getrandbits(32)) + if var_9 in var_12 and var_5.cookies.get(var_9) == var_12[var_9]: + var_3 += f'Welcome back: {var_8}
' + else: + var_12[var_9] = var_10 + var_3 += f'{var_8} has been remembered with cookie: {var_9} whose value is: {var_12[var_9]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00132.py b/Samples_Obfuscated/BenchmarkTest00132.py new file mode 100644 index 0000000..955f99d --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00132.py @@ -0,0 +1,29 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-00/BenchmarkTest00132', methods=['GET']) + def BenchmarkTest00132_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-00/BenchmarkTest00132', methods=['POST']) + def BenchmarkTest00132_post(): + var_3 = '' + var_4 = var_5.form.get('BenchmarkTest00132') + if not var_4: + var_4 = '' + import helpers.utils + var_6 = var_7.utils.escape_for_html(var_4) + import random + from helpers.utils import mysession + var_8 = 'BenchmarkTest00132'[13:] + var_9 = f'SafeNancy{var_8}' + var_10 = f'rememberMe{var_8}' + var_11 = str(var_12.SystemRandom().normalvariate())[2:] + if var_10 in var_13 and var_5.cookies.get(var_10) == var_13[var_10]: + var_3 += f'Welcome back: {var_9}
' + else: + var_13[var_10] = var_11 + var_3 += f'{var_9} has been remembered with cookie: {var_10} whose value is: {var_13[var_10]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00136.py b/Samples_Obfuscated/BenchmarkTest00136.py new file mode 100644 index 0000000..76f5c8f --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00136.py @@ -0,0 +1,35 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-00/BenchmarkTest00136', methods=['GET']) + def BenchmarkTest00136_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-00/BenchmarkTest00136', methods=['POST']) + def BenchmarkTest00136_post(): + var_3 = '' + var_4 = var_5.form.get('BenchmarkTest00136') + if not var_4: + var_4 = '' + var_6 = '' + var_7 = '' + var_8 = var_6 + var_6 = '' + var_6 += var_4 + var_8 += 'SomeOKString' + var_9 = var_8 + import random + import base64 + from helpers.utils import mysession + var_10 = 'BenchmarkTest00136'[13:] + var_11 = f'SafeBarbara{var_10}' + var_12 = f'rememberMe{var_10}' + var_13 = str(var_14.b64encode(var_15.SystemRandom().randbytes(32))) + if var_12 in var_16 and var_5.cookies.get(var_12) == var_16[var_12]: + var_3 += f'Welcome back: {var_11}
' + else: + var_16[var_12] = var_13 + var_3 += f'{var_11} has been remembered with cookie: {var_12} whose value is: {var_16[var_12]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00139.py b/Samples_Obfuscated/BenchmarkTest00139.py new file mode 100644 index 0000000..7e3a6a8 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00139.py @@ -0,0 +1,35 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-00/BenchmarkTest00139', methods=['GET']) + def BenchmarkTest00139_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-00/BenchmarkTest00139', methods=['POST']) + def BenchmarkTest00139_post(): + var_3 = '' + var_4 = var_5.form.get('BenchmarkTest00139') + if not var_4: + var_4 = '' + var_6 = '' + if var_4: + var_7 = [] + var_7.append('safe') + var_7.append(var_4) + var_7.append('moresafe') + var_7.pop(0) + var_6 = var_7[0] + import random + from helpers.utils import mysession + var_8 = 'BenchmarkTest00139'[13:] + var_9 = f'SafeRandall{var_8}' + var_10 = f'rememberMe{var_8}' + var_11 = str(var_12.SystemRandom().random())[2:] + if var_10 in var_13 and var_5.cookies.get(var_10) == var_13[var_10]: + var_3 += f'Welcome back: {var_9}
' + else: + var_13[var_10] = var_11 + var_3 += f'{var_9} has been remembered with cookie: {var_10} whose value is: {var_13[var_10]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00142.py b/Samples_Obfuscated/BenchmarkTest00142.py new file mode 100644 index 0000000..a31ab9e --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00142.py @@ -0,0 +1,40 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/hash-00/BenchmarkTest00142', methods=['GET']) + def BenchmarkTest00142_get(): + return var_1() + + @var_2.route('/benchmark/hash-00/BenchmarkTest00142', methods=['POST']) + def BenchmarkTest00142_post(): + var_3 = '' + var_4 = var_5.form.get('BenchmarkTest00142') + if not var_4: + var_4 = '' + var_6 = {} + var_6['keyA-71621'] = 'a-Value' + var_6['keyB-71621'] = var_4 + var_6['keyC'] = 'another-Value' + var_7 = 'safe!' + var_7 = var_6['keyB-71621'] + var_7 = var_6['keyA-71621'] + import hashlib, base64 + import io, helpers.utils + input = '' + if isinstance(var_7, str): + input = var_7.encode('utf-8') + elif isinstance(var_7, var_8.IOBase): + input = var_7.read(1000) + if len(input) == 0: + var_3 += 'Cannot generate hash: Input was empty.' + return var_3 + hash = var_9.sha1() + hash.update(input) + var_10 = hash.digest() + var_11 = open(f'{var_12.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + var_11.write(f'hash_value={var_13.b64encode(var_10)}\n') + var_3 += f"Sensitive value '{var_12.utils.escape_for_html(input.decode('utf-8'))}' hashed and stored." + var_11.close() + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00143.py b/Samples_Obfuscated/BenchmarkTest00143.py new file mode 100644 index 0000000..0a93084 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00143.py @@ -0,0 +1,35 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/hash-00/BenchmarkTest00143', methods=['GET']) + def BenchmarkTest00143_get(): + return var_1() + + @var_2.route('/benchmark/hash-00/BenchmarkTest00143', methods=['POST']) + def BenchmarkTest00143_post(): + var_3 = '' + var_4 = var_5.form.get('BenchmarkTest00143') + if not var_4: + var_4 = '' + import html + var_6 = var_7.escape(var_4) + import hashlib, base64 + import io, helpers.utils + input = '' + if isinstance(var_6, str): + input = var_6.encode('utf-8') + elif isinstance(var_6, var_8.IOBase): + input = var_6.read(1000) + if len(input) == 0: + var_3 += 'Cannot generate hash: Input was empty.' + return var_3 + hash = var_9.sha1() + hash.update(input) + var_10 = hash.digest() + var_11 = open(f'{var_12.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + var_11.write(f'hash_value={var_13.b64encode(var_10)}\n') + var_3 += f"Sensitive value '{var_12.utils.escape_for_html(input.decode('utf-8'))}' hashed and stored." + var_11.close() + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00146.py b/Samples_Obfuscated/BenchmarkTest00146.py new file mode 100644 index 0000000..f60ef00 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00146.py @@ -0,0 +1,34 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/hash-00/BenchmarkTest00146', methods=['GET']) + def BenchmarkTest00146_get(): + return var_1() + + @var_2.route('/benchmark/hash-00/BenchmarkTest00146', methods=['POST']) + def BenchmarkTest00146_post(): + var_3 = '' + var_4 = var_5.form.get('BenchmarkTest00146') + if not var_4: + var_4 = '' + var_6 = var_4 + '_SafeStuff' + import hashlib, base64 + import io, helpers.utils + input = '' + if isinstance(var_6, str): + input = var_6.encode('utf-8') + elif isinstance(var_6, var_7.IOBase): + input = var_6.read(1000) + if len(input) == 0: + var_3 += 'Cannot generate hash: Input was empty.' + return var_3 + hash = var_8.sha384() + hash.update(input) + var_9 = hash.digest() + var_10 = open(f'{var_11.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + var_10.write(f'hash_value={var_12.b64encode(var_9)}\n') + var_3 += f"Sensitive value '{var_11.utils.escape_for_html(input.decode('utf-8'))}' hashed and stored." + var_10.close() + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00147.py b/Samples_Obfuscated/BenchmarkTest00147.py new file mode 100644 index 0000000..ecd26a2 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00147.py @@ -0,0 +1,34 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/hash-00/BenchmarkTest00147', methods=['GET']) + def BenchmarkTest00147_get(): + return var_1() + + @var_2.route('/benchmark/hash-00/BenchmarkTest00147', methods=['POST']) + def BenchmarkTest00147_post(): + var_3 = '' + var_4 = var_5.form.get('BenchmarkTest00147') + if not var_4: + var_4 = '' + var_6 = var_4 + import hashlib, base64 + import io, helpers.utils + input = '' + if isinstance(var_6, str): + input = var_6.encode('utf-8') + elif isinstance(var_6, var_7.IOBase): + input = var_6.read(1000) + if len(input) == 0: + var_3 += 'Cannot generate hash: Input was empty.' + return var_3 + hash = var_8.sha512() + hash.update(input) + var_9 = hash.digest() + var_10 = open(f'{var_11.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + var_10.write(f'hash_value={var_12.b64encode(var_9)}\n') + var_3 += f"Sensitive value '{var_11.utils.escape_for_html(input.decode('utf-8'))}' hashed and stored." + var_10.close() + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00162.py b/Samples_Obfuscated/BenchmarkTest00162.py new file mode 100644 index 0000000..868606c --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00162.py @@ -0,0 +1,34 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/codeinj-00/BenchmarkTest00162', methods=['GET']) + def BenchmarkTest00162_get(): + return var_1() + + @var_2.route('/benchmark/codeinj-00/BenchmarkTest00162', methods=['POST']) + def BenchmarkTest00162_post(): + var_3 = '' + var_4 = var_5.form.get('BenchmarkTest00162') + if not var_4: + var_4 = '' + var_6 = 'ABC' + var_7 = var_6[1] + match var_7: + case 'A': + var_8 = var_4 + case 'B': + var_8 = 'bob' + case 'C' | 'D': + var_8 = var_4 + case _: + var_8 = "bob's your uncle" + if not var_8.startswith("'") or not var_8.endswith("'") or "'" in var_8[1:-1]: + var_3 += 'Exec argument must be a plain string literal.' + return var_3 + try: + exec(var_8) + except: + var_3 += f"Error executing statement '{var_9(var_8)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00164.py b/Samples_Obfuscated/BenchmarkTest00164.py new file mode 100644 index 0000000..125c7a2 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00164.py @@ -0,0 +1,30 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/deserialization-00/BenchmarkTest00164', methods=['GET']) + def BenchmarkTest00164_get(): + return var_1() + + @var_2.route('/benchmark/deserialization-00/BenchmarkTest00164', methods=['POST']) + def BenchmarkTest00164_post(): + var_3 = '' + var_4 = var_5.form.get('BenchmarkTest00164') + if not var_4: + var_4 = '' + var_6 = 'help' + var_6 += var_4 + var_6 += 'snapes on a plane' + var_7 = var_6[4:-17] + import pickle + import base64 + import helpers.utils + var_8.utils.sharedstr = 'no pickles to be seen here' + try: + var_9 = var_10.loads(var_11.urlsafe_b64decode(var_7)) + except: + var_3 += 'Unpickling failed!' + return var_3 + var_3 += f'shared string is {var_8.utils.sharedstr}' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00176.py b/Samples_Obfuscated/BenchmarkTest00176.py new file mode 100644 index 0000000..881c115 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00176.py @@ -0,0 +1,41 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/pathtraver-00/BenchmarkTest00176', methods=['GET']) + def BenchmarkTest00176_get(): + return var_1() + + @var_2.route('/benchmark/pathtraver-00/BenchmarkTest00176', methods=['POST']) + def BenchmarkTest00176_post(): + var_3 = '' + var_4 = var_5.form.getlist('BenchmarkTest00176') + var_6 = '' + if var_4: + var_6 = var_4[0] + var_7 = 'ABC' + var_8 = var_7[1] + match var_8: + case 'A': + var_9 = var_6 + case 'B': + var_9 = 'bob' + case 'C' | 'D': + var_9 = var_6 + case _: + var_9 = "bob's your uncle" + import helpers.utils + try: + var_10 = f'{var_11.utils.TESTFILES_DIR}/{var_9}' + var_12 = open(var_10, 'wb') + var_3 += f'Now ready to write to file: {var_13(var_10)}' + except IOError as e: + var_3 += f"Problem reading from file '{var_13(var_10)}': {var_13(var_14.strerror)}" + finally: + try: + if var_12 is not None: + var_12.close() + except IOError: + pass + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00179.py b/Samples_Obfuscated/BenchmarkTest00179.py new file mode 100644 index 0000000..acf94cb --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00179.py @@ -0,0 +1,32 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/pathtraver-00/BenchmarkTest00179', methods=['GET']) + def BenchmarkTest00179_get(): + return var_1() + + @var_2.route('/benchmark/pathtraver-00/BenchmarkTest00179', methods=['POST']) + def BenchmarkTest00179_post(): + var_3 = '' + var_4 = var_5.form.getlist('BenchmarkTest00179') + var_6 = '' + if var_4: + var_6 = var_4[0] + var_7 = 'alsosafe' + if var_6: + var_8 = [] + var_8.append('safe') + var_8.append(var_6) + var_8.append('moresafe') + var_8.pop(0) + var_7 = var_8[1] + import os + import helpers.utils + var_9 = f'{var_10.utils.TESTFILES_DIR}/{var_7}' + if var_11.path.exists(var_9): + var_3 += f"File '{var_12(var_9)}' exists." + else: + var_3 += f"File '{var_12(var_9)}' does not exist." + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00187.py b/Samples_Obfuscated/BenchmarkTest00187.py new file mode 100644 index 0000000..a6a2d00 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00187.py @@ -0,0 +1,22 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xss-00/BenchmarkTest00187', methods=['GET']) + def BenchmarkTest00187_get(): + return var_1() + + @var_2.route('/benchmark/xss-00/BenchmarkTest00187', methods=['POST']) + def BenchmarkTest00187_post(): + var_3 = '' + var_4 = var_5.form.getlist('BenchmarkTest00187') + var_6 = '' + if var_4: + var_6 = var_4[0] + import base64 + var_7 = var_8.b64encode(var_6.encode('utf-8')) + var_9 = var_8.b64decode(var_7).decode('utf-8') + var_10 = 'static text' + var_3 += "bar is '{0}' and otherarg is '{1}'".format(var_9, var_10) + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00190.py b/Samples_Obfuscated/BenchmarkTest00190.py new file mode 100644 index 0000000..612d70b --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00190.py @@ -0,0 +1,21 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xss-00/BenchmarkTest00190', methods=['GET']) + def BenchmarkTest00190_get(): + return var_1() + + @var_2.route('/benchmark/xss-00/BenchmarkTest00190', methods=['POST']) + def BenchmarkTest00190_post(): + var_3 = '' + var_4 = var_5.form.getlist('BenchmarkTest00190') + var_6 = '' + if var_4: + var_6 = var_4[0] + import html + var_7 = var_8.escape(var_6) + var_9 = 'static text' + var_3 += "bar is '%s' and otherarg is '%s'" % (var_7, var_9) + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00192.py b/Samples_Obfuscated/BenchmarkTest00192.py new file mode 100644 index 0000000..57613de --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00192.py @@ -0,0 +1,35 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/sqli-00/BenchmarkTest00192', methods=['GET']) + def BenchmarkTest00192_get(): + return var_1() + + @var_2.route('/benchmark/sqli-00/BenchmarkTest00192', methods=['POST']) + def BenchmarkTest00192_post(): + var_3 = '' + var_4 = var_5.form.getlist('BenchmarkTest00192') + var_6 = '' + if var_4: + var_6 = var_4[0] + var_7 = 'ABC' + var_8 = var_7[1] + match var_8: + case 'A': + var_9 = var_6 + case 'B': + var_9 = 'bob' + case 'C' | 'D': + var_9 = var_6 + case _: + var_9 = "bob's your uncle" + import helpers.db_sqlite + var_10 = f'SELECT username from USERS where password = ?' + var_11 = var_12.db_sqlite.get_connection() + var_13 = var_11.cursor() + var_13.execute(var_10, (var_9,)) + var_3 += var_12.db_sqlite.results(var_13, var_10) + var_11.close() + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00194.py b/Samples_Obfuscated/BenchmarkTest00194.py new file mode 100644 index 0000000..2c93982 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00194.py @@ -0,0 +1,35 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xpathi-00/BenchmarkTest00194', methods=['GET']) + def BenchmarkTest00194_get(): + return var_1() + + @var_2.route('/benchmark/xpathi-00/BenchmarkTest00194', methods=['POST']) + def BenchmarkTest00194_post(): + var_3 = '' + var_4 = var_5.form.getlist('BenchmarkTest00194') + var_6 = '' + if var_4: + var_6 = var_4[0] + var_7 = 86 + if 7 * 42 - var_7 > 200: + var_8 = 'This_should_always_happen' + else: + var_8 = var_6 + import elementpath + import xml.etree.ElementTree as ET + import helpers.utils + try: + var_9 = var_10.parse(f'{var_11.utils.RES_DIR}/employees.xml') + var_12 = f"/Employees/Employee[@emplid='{var_8}']" + var_13 = var_14.select(var_9, var_12) + var_15 = [] + for var_16 in var_13: + var_15.append(' '.join([var_17.text for var_17 in var_16])) + var_3 += f"Your XPATH query results are:
[ {', '.join(var_15)} ]" + except: + var_3 += f"Error parsing XPath Query: '{var_18(var_12)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00199.py b/Samples_Obfuscated/BenchmarkTest00199.py new file mode 100644 index 0000000..eb7d192 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00199.py @@ -0,0 +1,30 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xpathi-00/BenchmarkTest00199', methods=['GET']) + def BenchmarkTest00199_get(): + return var_1() + + @var_2.route('/benchmark/xpathi-00/BenchmarkTest00199', methods=['POST']) + def BenchmarkTest00199_post(): + var_3 = '' + var_4 = var_5.form.getlist('BenchmarkTest00199') + var_6 = '' + if var_4: + var_6 = var_4[0] + var_7 = var_6 + import elementpath + import xml.etree.ElementTree as ET + import helpers.utils + try: + var_8 = var_9.parse(f'{var_10.utils.RES_DIR}/employees.xml') + var_11 = var_12.select(var_8, f"""/Employees/Employee[@emplid='{var_7.replace("'", ''')}']""") + var_13 = [] + for var_14 in var_11: + var_13.append(' '.join([var_15.text for var_15 in var_14])) + var_3 += f"Your XPATH query results are:
[ {', '.join(var_13)} ]" + except: + var_3 += f"Error parsing XPath Query: '{var_16(var_17)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00202.py b/Samples_Obfuscated/BenchmarkTest00202.py new file mode 100644 index 0000000..2e46bb0 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00202.py @@ -0,0 +1,31 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xpathi-00/BenchmarkTest00202', methods=['GET']) + def BenchmarkTest00202_get(): + return var_1() + + @var_2.route('/benchmark/xpathi-00/BenchmarkTest00202', methods=['POST']) + def BenchmarkTest00202_post(): + var_3 = '' + var_4 = var_5.form.getlist('BenchmarkTest00202') + var_6 = '' + if var_4: + var_6 = var_4[0] + var_7 = 106 + var_8 = 'This should never happen' if 7 * 42 - var_7 > 200 else var_6 + import elementpath + import xml.etree.ElementTree as ET + import helpers.utils + try: + var_9 = var_10.parse(f'{var_11.utils.RES_DIR}/employees.xml') + var_12 = var_13.select(var_9, f"""/Employees/Employee[@emplid='{var_8.replace("'", ''')}']""") + var_14 = [] + for var_15 in var_12: + var_14.append(' '.join([var_16.text for var_16 in var_15])) + var_3 += f"Your XPATH query results are:
[ {', '.join(var_14)} ]" + except: + var_3 += f"Error parsing XPath Query: '{var_17(var_18)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00207.py b/Samples_Obfuscated/BenchmarkTest00207.py new file mode 100644 index 0000000..77f1ab3 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00207.py @@ -0,0 +1,41 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xpathi-00/BenchmarkTest00207', methods=['GET']) + def BenchmarkTest00207_get(): + return var_1() + + @var_2.route('/benchmark/xpathi-00/BenchmarkTest00207', methods=['POST']) + def BenchmarkTest00207_post(): + var_3 = '' + var_4 = var_5.form.getlist('BenchmarkTest00207') + var_6 = '' + if var_4: + var_6 = var_4[0] + var_7 = 'ABC' + var_8 = var_7[0] + match var_8: + case 'A': + var_9 = var_6 + case 'B': + var_9 = 'bob' + case 'C' | 'D': + var_9 = var_6 + case _: + var_9 = "bob's your uncle" + import lxml.etree + import helpers.utils + try: + var_10 = open(f'{var_11.utils.RES_DIR}/employees.xml', 'rb') + var_12 = var_13.etree.parse(var_10) + var_14 = f"/Employees/Employee[@emplid='{var_9}']" + var_15 = var_12.xpath(var_14) + var_16 = [] + for var_17 in var_15: + var_16.append(' '.join([var_18.text for var_18 in var_17])) + var_3 += f"Your XPATH query results are:
[ {', '.join(var_16)} ]" + except: + var_3 += f"Error parsing XPath Query: '{var_19(var_14)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00210.py b/Samples_Obfuscated/BenchmarkTest00210.py new file mode 100644 index 0000000..a7f1789 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00210.py @@ -0,0 +1,35 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xpathi-00/BenchmarkTest00210', methods=['GET']) + def BenchmarkTest00210_get(): + return var_1() + + @var_2.route('/benchmark/xpathi-00/BenchmarkTest00210', methods=['POST']) + def BenchmarkTest00210_post(): + var_3 = '' + var_4 = var_5.form.getlist('BenchmarkTest00210') + var_6 = '' + if var_4: + var_6 = var_4[0] + var_7 = 'This should never happen' + if 'should' not in var_7: + var_8 = 'Ifnot case passed' + else: + var_8 = var_6 + import lxml.etree + import helpers.utils + try: + var_9 = open(f'{var_10.utils.RES_DIR}/employees.xml', 'rb') + var_11 = var_12.etree.parse(var_9) + var_13 = "/Employees/Employee[@emplid='" + var_8 + "']" + var_14 = var_11.xpath(var_13) + var_15 = [] + for var_16 in var_14: + var_15.append(' '.join([var_17.text for var_17 in var_16])) + var_3 += f"Your XPATH query results are:
[ {', '.join(var_15)} ]" + except: + var_3 += f"Error parsing XPath Query: '{var_18(var_13)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00218.py b/Samples_Obfuscated/BenchmarkTest00218.py new file mode 100644 index 0000000..984a1b6 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00218.py @@ -0,0 +1,39 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-00/BenchmarkTest00218', methods=['GET']) + def BenchmarkTest00218_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-00/BenchmarkTest00218', methods=['POST']) + def BenchmarkTest00218_post(): + var_3 = '' + var_4 = var_5.form.getlist('BenchmarkTest00218') + var_6 = '' + if var_4: + var_6 = var_4[0] + var_7 = 'ABC' + var_8 = var_7[1] + match var_8: + case 'A': + var_9 = var_6 + case 'B': + var_9 = 'bob' + case 'C' | 'D': + var_9 = var_6 + case _: + var_9 = "bob's your uncle" + import random + from helpers.utils import mysession + var_10 = 'BenchmarkTest00218'[13:] + var_11 = f'Nancy{var_10}' + var_12 = f'rememberMe{var_10}' + var_13 = str(var_14.normalvariate())[2:] + if var_12 in var_15 and var_5.cookies.get(var_12) == var_15[var_12]: + var_3 += f'Welcome back: {var_11}
' + else: + var_15[var_12] = var_13 + var_3 += f'{var_11} has been remembered with cookie: {var_12} whose value is: {var_15[var_12]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00224.py b/Samples_Obfuscated/BenchmarkTest00224.py new file mode 100644 index 0000000..f08e212 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00224.py @@ -0,0 +1,29 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-00/BenchmarkTest00224', methods=['GET']) + def BenchmarkTest00224_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-00/BenchmarkTest00224', methods=['POST']) + def BenchmarkTest00224_post(): + var_3 = '' + var_4 = var_5.form.getlist('BenchmarkTest00224') + var_6 = '' + if var_4: + var_6 = var_4[0] + var_7 = var_6 + import random + from helpers.utils import mysession + var_8 = 'BenchmarkTest00224'[13:] + var_9 = f'Randall{var_8}' + var_10 = f'rememberMe{var_8}' + var_11 = str(var_12.random())[2:] + if var_10 in var_13 and var_5.cookies.get(var_10) == var_13[var_10]: + var_3 += f'Welcome back: {var_9}
' + else: + var_13[var_10] = var_11 + var_3 += f'{var_9} has been remembered with cookie: {var_10} whose value is: {var_13[var_10]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00225.py b/Samples_Obfuscated/BenchmarkTest00225.py new file mode 100644 index 0000000..b00c4b9 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00225.py @@ -0,0 +1,35 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-00/BenchmarkTest00225', methods=['GET']) + def BenchmarkTest00225_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-00/BenchmarkTest00225', methods=['POST']) + def BenchmarkTest00225_post(): + var_3 = '' + var_4 = var_5.form.getlist('BenchmarkTest00225') + var_6 = '' + if var_4: + var_6 = var_4[0] + import configparser + var_7 = 'safe!' + var_8 = var_9.ConfigParser() + var_8.add_section('section54571') + var_8.set('section54571', 'keyA-54571', 'a_Value') + var_8.set('section54571', 'keyB-54571', var_6) + var_7 = var_8.get('section54571', 'keyA-54571') + import random + from helpers.utils import mysession + var_10 = 'BenchmarkTest00225'[13:] + var_11 = f'Randall{var_10}' + var_12 = f'rememberMe{var_10}' + var_13 = str(var_14.random())[2:] + if var_12 in var_15 and var_5.cookies.get(var_12) == var_15[var_12]: + var_3 += f'Welcome back: {var_11}
' + else: + var_15[var_12] = var_13 + var_3 += f'{var_11} has been remembered with cookie: {var_12} whose value is: {var_15[var_12]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00229.py b/Samples_Obfuscated/BenchmarkTest00229.py new file mode 100644 index 0000000..ccf50a6 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00229.py @@ -0,0 +1,31 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-00/BenchmarkTest00229', methods=['GET']) + def BenchmarkTest00229_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-00/BenchmarkTest00229', methods=['POST']) + def BenchmarkTest00229_post(): + var_3 = '' + var_4 = var_5.form.getlist('BenchmarkTest00229') + var_6 = '' + if var_4: + var_6 = var_4[0] + var_7 = 'This should never happen' + if 'should' in var_7: + var_7 = var_6 + import secrets + from helpers.utils import mysession + var_8 = 'BenchmarkTest00229'[13:] + var_9 = f'SafeRobbie{var_8}' + var_10 = f'rememberMe{var_8}' + var_11 = str(var_12.randbelow(2 ** 32)) + if var_10 in var_13 and var_5.cookies.get(var_10) == var_13[var_10]: + var_3 += f'Welcome back: {var_9}
' + else: + var_13[var_10] = var_11 + var_3 += f'{var_9} has been remembered with cookie:{var_10} whose value is: {var_13[var_10]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00230.py b/Samples_Obfuscated/BenchmarkTest00230.py new file mode 100644 index 0000000..bea5a92 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00230.py @@ -0,0 +1,29 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-00/BenchmarkTest00230', methods=['GET']) + def BenchmarkTest00230_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-00/BenchmarkTest00230', methods=['POST']) + def BenchmarkTest00230_post(): + var_3 = '' + var_4 = var_5.form.getlist('BenchmarkTest00230') + var_6 = '' + if var_4: + var_6 = var_4[0] + var_7 = var_6 + '_SafeStuff' + import secrets + from helpers.utils import mysession + var_8 = 'BenchmarkTest00230'[13:] + var_9 = f'SafeRobbie{var_8}' + var_10 = f'rememberMe{var_8}' + var_11 = str(var_12.randbelow(2 ** 32)) + if var_10 in var_13 and var_5.cookies.get(var_10) == var_13[var_10]: + var_3 += f'Welcome back: {var_9}
' + else: + var_13[var_10] = var_11 + var_3 += f'{var_9} has been remembered with cookie:{var_10} whose value is: {var_13[var_10]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00235.py b/Samples_Obfuscated/BenchmarkTest00235.py new file mode 100644 index 0000000..f208663 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00235.py @@ -0,0 +1,32 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-00/BenchmarkTest00235', methods=['GET']) + def BenchmarkTest00235_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-00/BenchmarkTest00235', methods=['POST']) + def BenchmarkTest00235_post(): + var_3 = '' + var_4 = var_5.form.getlist('BenchmarkTest00235') + var_6 = '' + if var_4: + var_6 = var_4[0] + var_7 = '' + if var_6: + var_7 = var_6.split(' ')[0] + import base64 + import secrets + from helpers.utils import mysession + var_8 = 'BenchmarkTest00235'[13:] + var_9 = f'SafeTruman{var_8}' + var_10 = f'rememberMe{var_8}' + var_11 = var_12.token_urlsafe(32) + if var_10 in var_13 and var_5.cookies.get(var_10) == var_13[var_10]: + var_3 += f'Welcome back: {var_9}
' + else: + var_13[var_10] = var_11 + var_3 += f'{var_9} has been remembered with cookie:{var_10} whose value is: {var_13[var_10]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00248.py b/Samples_Obfuscated/BenchmarkTest00248.py new file mode 100644 index 0000000..41ab96d --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00248.py @@ -0,0 +1,41 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/hash-00/BenchmarkTest00248', methods=['GET']) + def BenchmarkTest00248_get(): + return var_1() + + @var_2.route('/benchmark/hash-00/BenchmarkTest00248', methods=['POST']) + def BenchmarkTest00248_post(): + var_3 = '' + var_4 = var_5.form.getlist('BenchmarkTest00248') + var_6 = '' + if var_4: + var_6 = var_4[0] + import configparser + var_7 = 'safe!' + var_8 = var_9.ConfigParser() + var_8.add_section('section78480') + var_8.set('section78480', 'keyA-78480', 'a_Value') + var_8.set('section78480', 'keyB-78480', var_6) + var_7 = var_8.get('section78480', 'keyA-78480') + import hashlib, base64 + import io, helpers.utils + input = '' + if isinstance(var_7, str): + input = var_7.encode('utf-8') + elif isinstance(var_7, var_10.IOBase): + input = var_7.read(1000) + if len(input) == 0: + var_3 += 'Cannot generate hash: Input was empty.' + return var_3 + hash = var_11.md5() + hash.update(input) + var_12 = hash.digest() + var_13 = open(f'{var_14.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + var_13.write(f'hash_value={var_15.b64encode(var_12)}\n') + var_3 += f"Sensitive value '{var_14.utils.escape_for_html(input.decode('utf-8'))}' hashed and stored." + var_13.close() + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00256.py b/Samples_Obfuscated/BenchmarkTest00256.py new file mode 100644 index 0000000..d1358c0 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00256.py @@ -0,0 +1,24 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xss-00/BenchmarkTest00256', methods=['GET']) + def BenchmarkTest00256_get(): + return var_1() + + @var_2.route('/benchmark/xss-00/BenchmarkTest00256', methods=['POST']) + def BenchmarkTest00256_post(): + var_3 = '' + var_4 = var_5.form.getlist('BenchmarkTest00256') + var_6 = '' + if var_4: + var_6 = var_4[0] + var_7 = 86 + if 7 * 42 - var_7 > 200: + var_8 = 'This_should_always_happen' + else: + var_8 = var_6 + var_3 += 'The value of the bar parameter is now in a custom header.' + var_3 = var_9((var_3, {'yourBenchmarkTest00256': var_8})) + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00258.py b/Samples_Obfuscated/BenchmarkTest00258.py new file mode 100644 index 0000000..388d467 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00258.py @@ -0,0 +1,20 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/redirect-00/BenchmarkTest00258', methods=['GET']) + def BenchmarkTest00258_get(): + return var_1() + + @var_2.route('/benchmark/redirect-00/BenchmarkTest00258', methods=['POST']) + def BenchmarkTest00258_post(): + var_3 = '' + var_4 = var_5.form.getlist('BenchmarkTest00258') + var_6 = '' + if var_4: + var_6 = var_4[0] + var_7 = var_6 + import flask + return var_8.redirect(var_7) + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00263.py b/Samples_Obfuscated/BenchmarkTest00263.py new file mode 100644 index 0000000..55039d4 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00263.py @@ -0,0 +1,32 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/codeinj-00/BenchmarkTest00263', methods=['GET']) + def BenchmarkTest00263_get(): + return var_1() + + @var_2.route('/benchmark/codeinj-00/BenchmarkTest00263', methods=['POST']) + def BenchmarkTest00263_post(): + var_3 = '' + var_4 = var_5.form.getlist('BenchmarkTest00263') + var_6 = '' + if var_4: + var_6 = var_4[0] + var_7 = 'ABC' + var_8 = var_7[1] + match var_8: + case 'A': + var_9 = var_6 + case 'B': + var_9 = 'bob' + case 'C' | 'D': + var_9 = var_6 + case _: + var_9 = "bob's your uncle" + try: + var_3 += eval(var_9) + except: + var_3 += f"Error evaluating expression '{var_10(var_9)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00271.py b/Samples_Obfuscated/BenchmarkTest00271.py new file mode 100644 index 0000000..2e07f91 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00271.py @@ -0,0 +1,34 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/deserialization-00/BenchmarkTest00271', methods=['GET']) + def BenchmarkTest00271_get(): + return var_1() + + @var_2.route('/benchmark/deserialization-00/BenchmarkTest00271', methods=['POST']) + def BenchmarkTest00271_post(): + var_3 = '' + var_4 = var_5.form.getlist('BenchmarkTest00271') + var_6 = '' + if var_4: + var_6 = var_4[0] + var_7 = 'ABC' + var_8 = var_7[0] + match var_8: + case 'A': + var_9 = var_6 + case 'B': + var_9 = 'bob' + case 'C' | 'D': + var_9 = var_6 + case _: + var_9 = "bob's your uncle" + import yaml + try: + var_10 = var_11.safe_load(var_9) + var_3 += var_10['text'] + except: + var_3 += 'There was an error loading the configuration' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00284.py b/Samples_Obfuscated/BenchmarkTest00284.py new file mode 100644 index 0000000..ab28445 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00284.py @@ -0,0 +1,28 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/sqli-00/BenchmarkTest00284', methods=['GET']) + def BenchmarkTest00284_get(): + return var_1() + + @var_2.route('/benchmark/sqli-00/BenchmarkTest00284', methods=['POST']) + def BenchmarkTest00284_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_form_parameter('BenchmarkTest00284') + if not var_7: + var_7 = '' + var_8 = 'This should never happen' + if 'should' in var_8: + var_8 = var_7 + import helpers.db_sqlite + var_9 = f"SELECT username from USERS where password = '{var_8}'" + var_10 = var_5.db_sqlite.get_connection() + var_11 = var_10.cursor() + var_11.execute(var_9) + var_3 += var_5.db_sqlite.results(var_11, var_9) + var_10.close() + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00286.py b/Samples_Obfuscated/BenchmarkTest00286.py new file mode 100644 index 0000000..39207a6 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00286.py @@ -0,0 +1,32 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/sqli-00/BenchmarkTest00286', methods=['GET']) + def BenchmarkTest00286_get(): + return var_1() + + @var_2.route('/benchmark/sqli-00/BenchmarkTest00286', methods=['POST']) + def BenchmarkTest00286_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_form_parameter('BenchmarkTest00286') + if not var_7: + var_7 = '' + import configparser + var_8 = 'safe!' + var_9 = var_10.ConfigParser() + var_9.add_section('section59255') + var_9.set('section59255', 'keyA-59255', 'a_Value') + var_9.set('section59255', 'keyB-59255', var_7) + var_8 = var_9.get('section59255', 'keyA-59255') + import helpers.db_sqlite + var_11 = f'SELECT username from USERS where password = ?' + var_12 = var_5.db_sqlite.get_connection() + var_13 = var_12.cursor() + var_13.execute(var_11, (var_8,)) + var_3 += var_5.db_sqlite.results(var_13, var_11) + var_12.close() + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00293.py b/Samples_Obfuscated/BenchmarkTest00293.py new file mode 100644 index 0000000..2442710 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00293.py @@ -0,0 +1,36 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xxe-00/BenchmarkTest00293', methods=['GET']) + def BenchmarkTest00293_get(): + return var_1() + + @var_2.route('/benchmark/xxe-00/BenchmarkTest00293', methods=['POST']) + def BenchmarkTest00293_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_form_parameter('BenchmarkTest00293') + if not var_7: + var_7 = '' + var_8 = 106 + var_9 = 'This should never happen' if 7 * 42 - var_8 > 200 else var_7 + import xml.dom.minidom + import xml.sax.handler + try: + var_10 = var_11.sax.make_parser() + var_12 = var_11.dom.minidom.parseString(var_9, var_10) + var_13 = '' + var_14 = [var_12.documentElement] + while var_14: + var_15 = var_14.pop(0) + if var_15.nodeType == var_11.dom.Node.TEXT_NODE: + var_13 += var_15.data + else: + var_14[:0] = var_15.childNodes + var_3 += f'Your XML doc results are:
{var_16(var_13)}' + except: + var_3 += f'There was an error reading your XML doc:
{var_16(var_9)}' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00314.py b/Samples_Obfuscated/BenchmarkTest00314.py new file mode 100644 index 0000000..8ffdaa4 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00314.py @@ -0,0 +1,34 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-01/BenchmarkTest00314', methods=['GET']) + def BenchmarkTest00314_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-01/BenchmarkTest00314', methods=['POST']) + def BenchmarkTest00314_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_form_parameter('BenchmarkTest00314') + if not var_7: + var_7 = '' + var_8 = 86 + if 7 * 42 - var_8 > 200: + var_9 = 'This_should_always_happen' + else: + var_9 = var_7 + import random + from helpers.utils import mysession + var_8 = 'BenchmarkTest00314'[13:] + var_10 = f'SafeRandy{var_8}' + var_11 = f'rememberMe{var_8}' + var_12 = str(var_13.SystemRandom().getrandbits(32)) + if var_11 in var_14 and var_6.cookies.get(var_11) == var_14[var_11]: + var_3 += f'Welcome back: {var_10}
' + else: + var_14[var_11] = var_12 + var_3 += f'{var_10} has been remembered with cookie: {var_11} whose value is: {var_14[var_11]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00319.py b/Samples_Obfuscated/BenchmarkTest00319.py new file mode 100644 index 0000000..82dd1a9 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00319.py @@ -0,0 +1,37 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/hash-00/BenchmarkTest00319', methods=['GET']) + def BenchmarkTest00319_get(): + return var_1() + + @var_2.route('/benchmark/hash-00/BenchmarkTest00319', methods=['POST']) + def BenchmarkTest00319_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_form_parameter('BenchmarkTest00319') + if not var_7: + var_7 = '' + import helpers.utils + var_8 = var_5.utils.escape_for_html(var_7) + import hashlib, base64 + import io, helpers.utils + input = '' + if isinstance(var_8, str): + input = var_8.encode('utf-8') + elif isinstance(var_8, var_9.IOBase): + input = var_8.read(1000) + if len(input) == 0: + var_3 += 'Cannot generate hash: Input was empty.' + return var_3 + hash = var_10.new('md5') + hash.update(input) + var_11 = hash.digest() + var_12 = open(f'{var_5.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + var_12.write(f'hash_value={var_13.b64encode(var_11)}\n') + var_3 += f"Sensitive value '{var_5.utils.escape_for_html(input.decode('utf-8'))}' hashed and stored." + var_12.close() + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00324.py b/Samples_Obfuscated/BenchmarkTest00324.py new file mode 100644 index 0000000..7704048 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00324.py @@ -0,0 +1,36 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/hash-00/BenchmarkTest00324', methods=['GET']) + def BenchmarkTest00324_get(): + return var_1() + + @var_2.route('/benchmark/hash-00/BenchmarkTest00324', methods=['POST']) + def BenchmarkTest00324_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_form_parameter('BenchmarkTest00324') + if not var_7: + var_7 = '' + var_8 = var_7 + import hashlib, base64 + import io, helpers.utils + input = '' + if isinstance(var_8, str): + input = var_8.encode('utf-8') + elif isinstance(var_8, var_9.IOBase): + input = var_8.read(1000) + if len(input) == 0: + var_3 += 'Cannot generate hash: Input was empty.' + return var_3 + hash = var_10.new('sha512') + hash.update(input) + var_11 = hash.digest() + var_12 = open(f'{var_5.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + var_12.write(f'hash_value={var_13.b64encode(var_11)}\n') + var_3 += f"Sensitive value '{var_5.utils.escape_for_html(input.decode('utf-8'))}' hashed and stored." + var_12.close() + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00327.py b/Samples_Obfuscated/BenchmarkTest00327.py new file mode 100644 index 0000000..99343a0 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00327.py @@ -0,0 +1,42 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/hash-00/BenchmarkTest00327', methods=['GET']) + def BenchmarkTest00327_get(): + return var_1() + + @var_2.route('/benchmark/hash-00/BenchmarkTest00327', methods=['POST']) + def BenchmarkTest00327_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_form_parameter('BenchmarkTest00327') + if not var_7: + var_7 = '' + import configparser + var_8 = 'safe!' + var_9 = var_10.ConfigParser() + var_9.add_section('section75704') + var_9.set('section75704', 'keyA-75704', 'a_Value') + var_9.set('section75704', 'keyB-75704', var_7) + var_8 = var_9.get('section75704', 'keyA-75704') + import hashlib, base64 + import io, helpers.utils + input = '' + if isinstance(var_8, str): + input = var_8.encode('utf-8') + elif isinstance(var_8, var_11.IOBase): + input = var_8.read(1000) + if len(input) == 0: + var_3 += 'Cannot generate hash: Input was empty.' + return var_3 + hash = var_12.md5() + hash.update(input) + var_13 = hash.digest() + var_14 = open(f'{var_5.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + var_14.write(f'hash_value={var_15.b64encode(var_13)}\n') + var_3 += f"Sensitive value '{var_5.utils.escape_for_html(input.decode('utf-8'))}' hashed and stored." + var_14.close() + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00328.py b/Samples_Obfuscated/BenchmarkTest00328.py new file mode 100644 index 0000000..d858b6c --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00328.py @@ -0,0 +1,36 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/hash-00/BenchmarkTest00328', methods=['GET']) + def BenchmarkTest00328_get(): + return var_1() + + @var_2.route('/benchmark/hash-00/BenchmarkTest00328', methods=['POST']) + def BenchmarkTest00328_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_form_parameter('BenchmarkTest00328') + if not var_7: + var_7 = '' + var_8 = var_7 + import hashlib, base64 + import io, helpers.utils + input = '' + if isinstance(var_8, str): + input = var_8.encode('utf-8') + elif isinstance(var_8, var_9.IOBase): + input = var_8.read(1000) + if len(input) == 0: + var_3 += 'Cannot generate hash: Input was empty.' + return var_3 + hash = var_10.sha1() + hash.update(input) + var_11 = hash.digest() + var_12 = open(f'{var_5.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + var_12.write(f'hash_value={var_13.b64encode(var_11)}\n') + var_3 += f"Sensitive value '{var_5.utils.escape_for_html(input.decode('utf-8'))}' hashed and stored." + var_12.close() + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00331.py b/Samples_Obfuscated/BenchmarkTest00331.py new file mode 100644 index 0000000..1b2449c --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00331.py @@ -0,0 +1,37 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/hash-00/BenchmarkTest00331', methods=['GET']) + def BenchmarkTest00331_get(): + return var_1() + + @var_2.route('/benchmark/hash-00/BenchmarkTest00331', methods=['POST']) + def BenchmarkTest00331_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_form_parameter('BenchmarkTest00331') + if not var_7: + var_7 = '' + import helpers.utils + var_8 = var_5.utils.escape_for_html(var_7) + import hashlib, base64 + import io, helpers.utils + input = '' + if isinstance(var_8, str): + input = var_8.encode('utf-8') + elif isinstance(var_8, var_9.IOBase): + input = var_8.read(1000) + if len(input) == 0: + var_3 += 'Cannot generate hash: Input was empty.' + return var_3 + hash = var_10.sha512() + hash.update(input) + var_11 = hash.digest() + var_12 = open(f'{var_5.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + var_12.write(f'hash_value={var_13.b64encode(var_11)}\n') + var_3 += f"Sensitive value '{var_5.utils.escape_for_html(input.decode('utf-8'))}' hashed and stored." + var_12.close() + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00334.py b/Samples_Obfuscated/BenchmarkTest00334.py new file mode 100644 index 0000000..58c75c5 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00334.py @@ -0,0 +1,25 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xss-00/BenchmarkTest00334', methods=['GET']) + def BenchmarkTest00334_get(): + return var_1() + + @var_2.route('/benchmark/xss-00/BenchmarkTest00334', methods=['POST']) + def BenchmarkTest00334_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_form_parameter('BenchmarkTest00334') + if not var_7: + var_7 = '' + var_8 = 'This should never happen' + if 'should' not in var_8: + var_9 = 'Ifnot case passed' + else: + var_9 = var_7 + var_3 += 'The value of the bar parameter is now in a custom header.' + var_3 = var_10((var_3, {'yourBenchmarkTest00334': var_9})) + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00335.py b/Samples_Obfuscated/BenchmarkTest00335.py new file mode 100644 index 0000000..4741118 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00335.py @@ -0,0 +1,25 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xss-00/BenchmarkTest00335', methods=['GET']) + def BenchmarkTest00335_get(): + return var_1() + + @var_2.route('/benchmark/xss-00/BenchmarkTest00335', methods=['POST']) + def BenchmarkTest00335_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_form_parameter('BenchmarkTest00335') + if not var_7: + var_7 = '' + var_8 = 86 + if 7 * 42 - var_8 > 200: + var_9 = 'This_should_always_happen' + else: + var_9 = var_7 + var_3 += 'The value of the bar parameter is now in a custom header.' + var_3 = var_10((var_3, {'yourBenchmarkTest00335': var_9})) + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00339.py b/Samples_Obfuscated/BenchmarkTest00339.py new file mode 100644 index 0000000..963ddc4 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00339.py @@ -0,0 +1,26 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/trustbound-00/BenchmarkTest00339', methods=['GET']) + def BenchmarkTest00339_get(): + return var_1() + + @var_2.route('/benchmark/trustbound-00/BenchmarkTest00339', methods=['POST']) + def BenchmarkTest00339_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_form_parameter('BenchmarkTest00339') + if not var_7: + var_7 = '' + var_8 = 86 + if 7 * 42 - var_8 > 200: + var_9 = 'This_should_always_happen' + else: + var_9 = var_7 + import flask + var_10.session['userid'] = var_9 + var_3 += f"Item: 'userid' with value '{var_11(var_9)}'saved in session." + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00351.py b/Samples_Obfuscated/BenchmarkTest00351.py new file mode 100644 index 0000000..43f41d6 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00351.py @@ -0,0 +1,27 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/pathtraver-00/BenchmarkTest00351', methods=['GET']) + def BenchmarkTest00351_get(): + return var_1() + + @var_2.route('/benchmark/pathtraver-00/BenchmarkTest00351', methods=['POST']) + def BenchmarkTest00351_post(): + var_3 = '' + var_4 = '' + for var_5 in var_6.form.keys(): + if 'BenchmarkTest00351' in var_6.form.getlist(var_5): + var_4 = var_5 + break + var_7 = var_4 + import codecs + import helpers.utils + try: + var_8 = var_9.open(f'{var_10.utils.TESTFILES_DIR}/{var_7}', 'r', 'utf-8') + var_3 += f"Access to file: '{var_11(var_8.name)}' created." + var_3 += ' And file already exists.' + except FileNotFoundError: + var_3 += " But file doesn't exist yet." + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00366.py b/Samples_Obfuscated/BenchmarkTest00366.py new file mode 100644 index 0000000..d4c21fc --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00366.py @@ -0,0 +1,25 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xss-00/BenchmarkTest00366', methods=['GET']) + def BenchmarkTest00366_get(): + return var_1() + + @var_2.route('/benchmark/xss-00/BenchmarkTest00366', methods=['POST']) + def BenchmarkTest00366_post(): + var_3 = '' + var_4 = '' + for var_5 in var_6.form.keys(): + if 'BenchmarkTest00366' in var_6.form.getlist(var_5): + var_4 = var_5 + break + var_7 = {} + var_7['keyA-99262'] = 'a-Value' + var_7['keyB-99262'] = var_4 + var_7['keyC'] = 'another-Value' + var_8 = var_7['keyB-99262'] + var_9 = 'static text' + var_3 += "bar is '%s' and otherarg is '%s'" % (var_8, var_9) + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00390.py b/Samples_Obfuscated/BenchmarkTest00390.py new file mode 100644 index 0000000..f0cf14c --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00390.py @@ -0,0 +1,32 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-01/BenchmarkTest00390', methods=['GET']) + def BenchmarkTest00390_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-01/BenchmarkTest00390', methods=['POST']) + def BenchmarkTest00390_post(): + var_3 = '' + var_4 = '' + for var_5 in var_6.form.keys(): + if 'BenchmarkTest00390' in var_6.form.getlist(var_5): + var_4 = var_5 + break + var_7 = 106 + var_8 = 'This_should_always_happen' if 7 * 18 + var_7 > 200 else var_4 + import base64 + import secrets + from helpers.utils import mysession + var_7 = 'BenchmarkTest00390'[13:] + var_9 = f'SafeToby{var_7}' + var_10 = f'rememberMe{var_7}' + var_11 = var_12.b64encode(var_13.token_bytes(32)) + if var_10 in var_14 and var_6.cookies.get(var_10) == var_14[var_10]: + var_3 += f'Welcome back: {var_9}
' + else: + var_14[var_10] = var_11 + var_3 += f'{var_9} has been remembered with cookie:{var_10} whose value is: {var_14[var_10]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00394.py b/Samples_Obfuscated/BenchmarkTest00394.py new file mode 100644 index 0000000..c784691 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00394.py @@ -0,0 +1,41 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-01/BenchmarkTest00394', methods=['GET']) + def BenchmarkTest00394_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-01/BenchmarkTest00394', methods=['POST']) + def BenchmarkTest00394_post(): + var_3 = '' + var_4 = '' + for var_5 in var_6.form.keys(): + if 'BenchmarkTest00394' in var_6.form.getlist(var_5): + var_4 = var_5 + break + var_7 = 'ABC' + var_8 = var_7[0] + match var_8: + case 'A': + var_9 = var_4 + case 'B': + var_9 = 'bob' + case 'C' | 'D': + var_9 = var_4 + case _: + var_9 = "bob's your uncle" + import base64 + import secrets + from helpers.utils import mysession + var_10 = 'BenchmarkTest00394'[13:] + var_11 = f'SafeTruman{var_10}' + var_12 = f'rememberMe{var_10}' + var_13 = var_14.token_urlsafe(32) + if var_12 in var_15 and var_6.cookies.get(var_12) == var_15[var_12]: + var_3 += f'Welcome back: {var_11}
' + else: + var_15[var_12] = var_13 + var_3 += f'{var_11} has been remembered with cookie:{var_12} whose value is: {var_15[var_12]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00408.py b/Samples_Obfuscated/BenchmarkTest00408.py new file mode 100644 index 0000000..e1699ae --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00408.py @@ -0,0 +1,31 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-01/BenchmarkTest00408', methods=['GET']) + def BenchmarkTest00408_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-01/BenchmarkTest00408', methods=['POST']) + def BenchmarkTest00408_post(): + var_3 = '' + var_4 = '' + for var_5 in var_6.form.keys(): + if 'BenchmarkTest00408' in var_6.form.getlist(var_5): + var_4 = var_5 + break + var_7 = 106 + var_8 = 'This_should_always_happen' if 7 * 18 + var_7 > 200 else var_4 + import random + from helpers.utils import mysession + var_7 = 'BenchmarkTest00408'[13:] + var_9 = f'SafeRandall{var_7}' + var_10 = f'rememberMe{var_7}' + var_11 = str(var_12.SystemRandom().random())[2:] + if var_10 in var_13 and var_6.cookies.get(var_10) == var_13[var_10]: + var_3 += f'Welcome back: {var_9}
' + else: + var_13[var_10] = var_11 + var_3 += f'{var_9} has been remembered with cookie: {var_10} whose value is: {var_13[var_10]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00412.py b/Samples_Obfuscated/BenchmarkTest00412.py new file mode 100644 index 0000000..2c12ec1 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00412.py @@ -0,0 +1,43 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/hash-00/BenchmarkTest00412', methods=['GET']) + def BenchmarkTest00412_get(): + return var_1() + + @var_2.route('/benchmark/hash-00/BenchmarkTest00412', methods=['POST']) + def BenchmarkTest00412_post(): + var_3 = '' + var_4 = '' + for var_5 in var_6.form.keys(): + if 'BenchmarkTest00412' in var_6.form.getlist(var_5): + var_4 = var_5 + break + var_7 = '' + if var_4: + var_8 = [] + var_8.append('safe') + var_8.append(var_4) + var_8.append('moresafe') + var_8.pop(0) + var_7 = var_8[0] + import hashlib, base64 + import io, helpers.utils + input = '' + if isinstance(var_7, str): + input = var_7.encode('utf-8') + elif isinstance(var_7, var_9.IOBase): + input = var_7.read(1000) + if len(input) == 0: + var_3 += 'Cannot generate hash: Input was empty.' + return var_3 + hash = var_10.md5() + hash.update(input) + var_11 = hash.digest() + var_12 = open(f'{var_13.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + var_12.write(f'hash_value={var_14.b64encode(var_11)}\n') + var_3 += f"Sensitive value '{var_13.utils.escape_for_html(input.decode('utf-8'))}' hashed and stored." + var_12.close() + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00430.py b/Samples_Obfuscated/BenchmarkTest00430.py new file mode 100644 index 0000000..778d092 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00430.py @@ -0,0 +1,38 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/ldapi-00/BenchmarkTest00430', methods=['GET']) + def BenchmarkTest00430_get(): + return var_1() + + @var_2.route('/benchmark/ldapi-00/BenchmarkTest00430', methods=['POST']) + def BenchmarkTest00430_post(): + var_3 = '' + var_4 = '' + for var_5 in var_6.form.keys(): + if 'BenchmarkTest00430' in var_6.form.getlist(var_5): + var_4 = var_5 + break + var_7 = 'help' + var_7 += var_4 + var_7 += 'snapes on a plane' + var_8 = var_7[4:-17] + import helpers.ldap + import ldap3 + var_9 = 'ou=users,ou=system' + filter = f'(&(objectclass=person)(uid={var_8}))' + try: + var_10 = var_11.ldap.get_connection() + var_10.search(var_9, filter, attributes=var_12.ALL_ATTRIBUTES) + var_13 = False + for var_14 in var_10.entries: + var_3 += f"LDAP query results:
Record found with name {var_14['uid']}
Address: {var_14['street']}
" + var_13 = True + var_10.unbind() + if not var_13: + var_3 += f'LDAP query results: nothing found for query: {var_11.utils.escape_for_html(filter)}' + except IOError: + var_3 += 'Error processing LDAP query.' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00433.py b/Samples_Obfuscated/BenchmarkTest00433.py new file mode 100644 index 0000000..45f2bf6 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00433.py @@ -0,0 +1,29 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/deserialization-00/BenchmarkTest00433', methods=['GET']) + def BenchmarkTest00433_get(): + return var_1() + + @var_2.route('/benchmark/deserialization-00/BenchmarkTest00433', methods=['POST']) + def BenchmarkTest00433_post(): + var_3 = '' + var_4 = '' + for var_5 in var_6.form.keys(): + if 'BenchmarkTest00433' in var_6.form.getlist(var_5): + var_4 = var_5 + break + var_7 = {} + var_7['keyA-74329'] = 'a-Value' + var_7['keyB-74329'] = var_4 + var_7['keyC'] = 'another-Value' + var_8 = var_7['keyB-74329'] + import yaml + try: + var_9 = var_10.load(var_8, Loader=var_10.Loader) + var_3 += var_9['text'] + except: + var_3 += 'There was an error loading the configuration' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00434.py b/Samples_Obfuscated/BenchmarkTest00434.py new file mode 100644 index 0000000..4ad4ead --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00434.py @@ -0,0 +1,27 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/deserialization-00/BenchmarkTest00434', methods=['GET']) + def BenchmarkTest00434_get(): + return var_1() + + @var_2.route('/benchmark/deserialization-00/BenchmarkTest00434', methods=['POST']) + def BenchmarkTest00434_post(): + var_3 = '' + var_4 = '' + for var_5 in var_6.form.keys(): + if 'BenchmarkTest00434' in var_6.form.getlist(var_5): + var_4 = var_5 + break + import helpers.ThingFactory + var_7 = var_8.ThingFactory.createThing() + var_9 = var_7.doSomething(var_4) + import yaml + try: + var_10 = var_11.safe_load(var_9) + var_3 += var_10['text'] + except: + var_3 += 'There was an error loading the configuration' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00436.py b/Samples_Obfuscated/BenchmarkTest00436.py new file mode 100644 index 0000000..143ca6c --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00436.py @@ -0,0 +1,25 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xss-00/BenchmarkTest00436', methods=['GET']) + def BenchmarkTest00436_get(): + return var_1() + + @var_2.route('/benchmark/xss-00/BenchmarkTest00436', methods=['POST']) + def BenchmarkTest00436_post(): + var_3 = '' + var_4 = var_5.headers.get('Referer') + if not var_4: + var_4 = '' + var_6 = 'alsosafe' + if var_4: + var_7 = [] + var_7.append('safe') + var_7.append(var_4) + var_7.append('moresafe') + var_7.pop(0) + var_6 = var_7[1] + var_3 += f'Parameter value: {var_6}' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00439.py b/Samples_Obfuscated/BenchmarkTest00439.py new file mode 100644 index 0000000..ab743b6 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00439.py @@ -0,0 +1,35 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/pathtraver-00/BenchmarkTest00439', methods=['GET']) + def BenchmarkTest00439_get(): + return var_1() + + @var_2.route('/benchmark/pathtraver-00/BenchmarkTest00439', methods=['POST']) + def BenchmarkTest00439_post(): + var_3 = '' + var_4 = var_5.headers.get('BenchmarkTest00439') + if not var_4: + var_4 = '' + var_6 = 'help' + var_6 += var_4 + var_6 += 'snapes on a plane' + var_7 = var_6[4:-17] + import helpers.utils + var_8 = None + var_9 = None + try: + var_8 = f'{var_10.utils.TESTFILES_DIR}/{var_7}' + var_9 = open(var_8, 'rb') + var_3 += f"The beginning of file: '{var_11(var_8)}' is:\n\n{var_11(var_9.read(1000).decode('utf-8'))}" + except IOError as e: + var_3 += f"Problem reading from file '{{escape_for_html(fileName)}}': {var_11(var_12.strerror)}" + finally: + try: + if var_9 is not None: + var_9.close() + except IOError: + pass + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00441.py b/Samples_Obfuscated/BenchmarkTest00441.py new file mode 100644 index 0000000..4a8cf06 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00441.py @@ -0,0 +1,31 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/pathtraver-00/BenchmarkTest00441', methods=['GET']) + def BenchmarkTest00441_get(): + return var_1() + + @var_2.route('/benchmark/pathtraver-00/BenchmarkTest00441', methods=['POST']) + def BenchmarkTest00441_post(): + var_3 = '' + var_4 = var_5.headers.get('BenchmarkTest00441') + if not var_4: + var_4 = '' + var_6 = 106 + var_7 = 'This_should_always_happen' if 7 * 18 + var_6 > 200 else var_4 + import helpers.utils + try: + var_8 = f'{var_9.utils.TESTFILES_DIR}/{var_7}' + var_10 = open(var_8, 'wb') + var_3 += f'Now ready to write to file: {var_11(var_8)}' + except IOError as e: + var_3 += f"Problem reading from file '{var_11(var_8)}': {var_11(var_12.strerror)}" + finally: + try: + if var_10 is not None: + var_10.close() + except IOError: + pass + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00448.py b/Samples_Obfuscated/BenchmarkTest00448.py new file mode 100644 index 0000000..e3b2c55 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00448.py @@ -0,0 +1,34 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/pathtraver-00/BenchmarkTest00448', methods=['GET']) + def BenchmarkTest00448_get(): + return var_1() + + @var_2.route('/benchmark/pathtraver-00/BenchmarkTest00448', methods=['POST']) + def BenchmarkTest00448_post(): + var_3 = '' + var_4 = var_5.headers.get('BenchmarkTest00448') + if not var_4: + var_4 = '' + import configparser + var_6 = 'safe!' + var_7 = var_8.ConfigParser() + var_7.add_section('section57737') + var_7.set('section57737', 'keyA-57737', 'a_Value') + var_7.set('section57737', 'keyB-57737', var_4) + var_6 = var_7.get('section57737', 'keyA-57737') + import pathlib + import helpers.utils + try: + var_9 = var_10.Path(var_11.utils.TESTFILES_DIR) + var_12 = (var_9 / var_6).resolve() + if not str(var_12).startswith(str(var_9)): + var_3 += 'Invalid Path.' + return var_3 + var_3 += f"The beginning of file: '{var_13(str(var_12))}' is:\n\n{var_13(var_12.read_text()[:1000])}" + except OSError: + var_3 += f"Problem reading from file '{{escape_for_html(fileName)}}': {var_13(var_14.strerror)}" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00450.py b/Samples_Obfuscated/BenchmarkTest00450.py new file mode 100644 index 0000000..224cbc6 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00450.py @@ -0,0 +1,21 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xss-00/BenchmarkTest00450', methods=['GET']) + def BenchmarkTest00450_get(): + return var_1() + + @var_2.route('/benchmark/xss-00/BenchmarkTest00450', methods=['POST']) + def BenchmarkTest00450_post(): + var_3 = '' + var_4 = var_5.headers.get('Referer') + if not var_4: + var_4 = '' + var_6 = 'This should never happen' + if 'should' in var_6: + var_6 = var_4 + var_7 = 'static text' + var_3 += "bar is '{0}' and otherarg is '{1}'".format(var_6, var_7) + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00452.py b/Samples_Obfuscated/BenchmarkTest00452.py new file mode 100644 index 0000000..b951c78 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00452.py @@ -0,0 +1,22 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xss-00/BenchmarkTest00452', methods=['GET']) + def BenchmarkTest00452_get(): + return var_1() + + @var_2.route('/benchmark/xss-00/BenchmarkTest00452', methods=['POST']) + def BenchmarkTest00452_post(): + var_3 = '' + var_4 = var_5.headers.get('Referer') + if not var_4: + var_4 = '' + import html + var_6 = var_7.escape(var_4) + dict = {} + dict['bar'] = var_6 + dict['otherarg'] = 'this is it' + var_3 += "bar is '{0[bar]}' and otherarg is '{0[otherarg]}'".format(dict) + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00458.py b/Samples_Obfuscated/BenchmarkTest00458.py new file mode 100644 index 0000000..bf58951 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00458.py @@ -0,0 +1,34 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xpathi-00/BenchmarkTest00458', methods=['GET']) + def BenchmarkTest00458_get(): + return var_1() + + @var_2.route('/benchmark/xpathi-00/BenchmarkTest00458', methods=['POST']) + def BenchmarkTest00458_post(): + var_3 = '' + var_4 = var_5.headers.get('BenchmarkTest00458') + if not var_4: + var_4 = '' + var_6 = 106 + var_7 = 'This_should_always_happen' if 7 * 18 + var_6 > 200 else var_4 + import elementpath + import xml.etree.ElementTree as ET + import helpers.utils + if "'" in var_7: + var_3 += 'Employee ID must not contain apostrophes' + return var_3 + try: + var_8 = var_9.parse(f'{var_10.utils.RES_DIR}/employees.xml') + var_11 = f"/Employees/Employee[@emplid='{var_7}']" + var_12 = var_13.select(var_8, var_11) + var_14 = [] + for var_15 in var_12: + var_14.append(' '.join([var_16.text for var_16 in var_15])) + var_3 += f"Your XPATH query results are:
[ {', '.join(var_14)} ]" + except: + var_3 += f"Error parsing XPath Query: '{var_17(var_11)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00461.py b/Samples_Obfuscated/BenchmarkTest00461.py new file mode 100644 index 0000000..2f7ca22 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00461.py @@ -0,0 +1,40 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xxe-00/BenchmarkTest00461', methods=['GET']) + def BenchmarkTest00461_get(): + return var_1() + + @var_2.route('/benchmark/xxe-00/BenchmarkTest00461', methods=['POST']) + def BenchmarkTest00461_post(): + var_3 = '' + var_4 = var_5.headers.get('BenchmarkTest00461') + if not var_4: + var_4 = '' + var_6 = {} + var_6['keyA-63945'] = 'a-Value' + var_6['keyB-63945'] = var_4 + var_6['keyC'] = 'another-Value' + var_7 = 'safe!' + var_7 = var_6['keyB-63945'] + var_7 = var_6['keyA-63945'] + import xml.dom.minidom + import xml.sax.handler + try: + var_8 = var_9.sax.make_parser() + var_8.setFeature(var_9.sax.handler.feature_external_ges, True) + var_10 = var_9.dom.minidom.parseString(var_7, var_8) + var_11 = '' + var_12 = [var_10.documentElement] + while var_12: + var_13 = var_12.pop(0) + if var_13.nodeType == var_9.dom.Node.TEXT_NODE: + var_11 += var_13.data + else: + var_12[:0] = var_13.childNodes + var_3 += f'Your XML doc results are:
{var_14(var_11)}' + except: + var_3 += f'There was an error reading your XML doc:
{var_14(var_7)}' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00467.py b/Samples_Obfuscated/BenchmarkTest00467.py new file mode 100644 index 0000000..38df9a4 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00467.py @@ -0,0 +1,34 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xpathi-00/BenchmarkTest00467', methods=['GET']) + def BenchmarkTest00467_get(): + return var_1() + + @var_2.route('/benchmark/xpathi-00/BenchmarkTest00467', methods=['POST']) + def BenchmarkTest00467_post(): + var_3 = '' + var_4 = var_5.headers.get('BenchmarkTest00467') + if not var_4: + var_4 = '' + var_6 = 86 + if 7 * 42 - var_6 > 200: + var_7 = 'This_should_always_happen' + else: + var_7 = var_4 + import lxml.etree + import helpers.utils + try: + var_8 = open(f'{var_9.utils.RES_DIR}/employees.xml', 'rb') + var_10 = var_11.etree.parse(var_8) + var_12 = f"""/Employees/Employee[@emplid='{var_7.replace("'", ''')}']""" + var_13 = var_10.xpath(var_12) + var_14 = [] + for var_15 in var_13: + var_14.append(' '.join([var_16.text for var_16 in var_15])) + var_3 += f"Your XPATH query results are:
[ {', '.join(var_14)} ]" + except: + var_3 += f"Error parsing XPath Query: '{var_17(var_12)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00469.py b/Samples_Obfuscated/BenchmarkTest00469.py new file mode 100644 index 0000000..b1fa89e --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00469.py @@ -0,0 +1,32 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xpathi-01/BenchmarkTest00469', methods=['GET']) + def BenchmarkTest00469_get(): + return var_1() + + @var_2.route('/benchmark/xpathi-01/BenchmarkTest00469', methods=['POST']) + def BenchmarkTest00469_post(): + var_3 = '' + var_4 = var_5.headers.get('BenchmarkTest00469') + if not var_4: + var_4 = '' + import base64 + var_6 = var_7.b64encode(var_4.encode('utf-8')) + var_8 = var_7.b64decode(var_6).decode('utf-8') + import lxml.etree + import helpers.utils + try: + var_9 = open(f'{var_10.utils.RES_DIR}/employees.xml', 'rb') + var_11 = var_12.etree.parse(var_9) + var_13 = f'/Employees/Employee[@emplid=$name]' + var_14 = var_11.xpath(var_13, name=var_8) + var_15 = [] + for var_16 in var_14: + var_15.append(' '.join([var_17.text for var_17 in var_16])) + var_3 += f"Your XPATH query results are:
[ {', '.join(var_15)} ]" + except: + var_3 += f"Error parsing XPath Query: '{var_18(var_13)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00470.py b/Samples_Obfuscated/BenchmarkTest00470.py new file mode 100644 index 0000000..6f7da65 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00470.py @@ -0,0 +1,40 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xpathi-01/BenchmarkTest00470', methods=['GET']) + def BenchmarkTest00470_get(): + return var_1() + + @var_2.route('/benchmark/xpathi-01/BenchmarkTest00470', methods=['POST']) + def BenchmarkTest00470_post(): + var_3 = '' + var_4 = var_5.headers.get('BenchmarkTest00470') + if not var_4: + var_4 = '' + var_6 = 'ABC' + var_7 = var_6[1] + match var_7: + case 'A': + var_8 = var_4 + case 'B': + var_8 = 'bob' + case 'C' | 'D': + var_8 = var_4 + case _: + var_8 = "bob's your uncle" + import lxml.etree + import helpers.utils + try: + var_9 = open(f'{var_10.utils.RES_DIR}/employees.xml', 'rb') + var_11 = var_12.etree.parse(var_9) + var_13 = f'/Employees/Employee[@emplid=$name]' + var_14 = var_11.xpath(var_13, name=var_8) + var_15 = [] + for var_16 in var_14: + var_15.append(' '.join([var_17.text for var_17 in var_16])) + var_3 += f"Your XPATH query results are:
[ {', '.join(var_15)} ]" + except: + var_3 += f"Error parsing XPath Query: '{var_18(var_13)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00472.py b/Samples_Obfuscated/BenchmarkTest00472.py new file mode 100644 index 0000000..13f5ac7 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00472.py @@ -0,0 +1,37 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xpathi-01/BenchmarkTest00472', methods=['GET']) + def BenchmarkTest00472_get(): + return var_1() + + @var_2.route('/benchmark/xpathi-01/BenchmarkTest00472', methods=['POST']) + def BenchmarkTest00472_post(): + var_3 = '' + var_4 = var_5.headers.get('BenchmarkTest00472') + if not var_4: + var_4 = '' + import helpers.ThingFactory + var_6 = var_7.ThingFactory.createThing() + var_8 = var_6.doSomething(var_4) + import lxml.etree + import helpers.utils + import io + try: + var_9 = open(f'{var_7.utils.RES_DIR}/employees.xml', 'rb') + var_10 = var_11.etree.parse(var_9) + var_12 = var_13.StringIO() + var_12.write("/Employees/Employee[@emplid='") + var_12.write(var_8) + var_12.write("']") + var_14 = var_12.getvalue() + var_15 = var_10.xpath(var_14) + var_16 = [] + for var_17 in var_15: + var_16.append(' '.join([var_18.text for var_18 in var_17])) + var_3 += f"Your XPATH query results are:
[ {', '.join(var_16)} ]" + except: + var_3 += f"Error parsing XPath Query: '{var_19(var_14)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00477.py b/Samples_Obfuscated/BenchmarkTest00477.py new file mode 100644 index 0000000..fa7f746 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00477.py @@ -0,0 +1,32 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-01/BenchmarkTest00477', methods=['GET']) + def BenchmarkTest00477_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-01/BenchmarkTest00477', methods=['POST']) + def BenchmarkTest00477_post(): + var_3 = '' + var_4 = var_5.headers.get('BenchmarkTest00477') + if not var_4: + var_4 = '' + var_6 = 86 + if 7 * 42 - var_6 > 200: + var_7 = 'This_should_always_happen' + else: + var_7 = var_4 + import secrets + from helpers.utils import mysession + var_6 = 'BenchmarkTest00477'[13:] + var_8 = f'SafeRicky{var_6}' + var_9 = f'rememberMe{var_6}' + var_10 = str(var_11.randbits(32)) + if var_9 in var_12 and var_5.cookies.get(var_9) == var_12[var_9]: + var_3 += f'Welcome back: {var_8}
' + else: + var_12[var_9] = var_10 + var_3 += f'{var_8} has been remembered with cookie:{var_9} whose value is: {var_12[var_9]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00488.py b/Samples_Obfuscated/BenchmarkTest00488.py new file mode 100644 index 0000000..f954746 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00488.py @@ -0,0 +1,41 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/hash-00/BenchmarkTest00488', methods=['GET']) + def BenchmarkTest00488_get(): + return var_1() + + @var_2.route('/benchmark/hash-00/BenchmarkTest00488', methods=['POST']) + def BenchmarkTest00488_post(): + var_3 = '' + var_4 = var_5.headers.get('BenchmarkTest00488') + if not var_4: + var_4 = '' + var_6 = 'alsosafe' + if var_4: + var_7 = [] + var_7.append('safe') + var_7.append(var_4) + var_7.append('moresafe') + var_7.pop(0) + var_6 = var_7[1] + import hashlib, base64 + import io, helpers.utils + input = '' + if isinstance(var_6, str): + input = var_6.encode('utf-8') + elif isinstance(var_6, var_8.IOBase): + input = var_6.read(1000) + if len(input) == 0: + var_3 += 'Cannot generate hash: Input was empty.' + return var_3 + hash = var_9.new('sha512') + hash.update(input) + var_10 = hash.digest() + var_11 = open(f'{var_12.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + var_11.write(f'hash_value={var_13.b64encode(var_10)}\n') + var_3 += f"Sensitive value '{var_12.utils.escape_for_html(input.decode('utf-8'))}' hashed and stored." + var_11.close() + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00491.py b/Samples_Obfuscated/BenchmarkTest00491.py new file mode 100644 index 0000000..4b455b5 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00491.py @@ -0,0 +1,40 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/hash-00/BenchmarkTest00491', methods=['GET']) + def BenchmarkTest00491_get(): + return var_1() + + @var_2.route('/benchmark/hash-00/BenchmarkTest00491', methods=['POST']) + def BenchmarkTest00491_post(): + var_3 = '' + var_4 = var_5.headers.get('BenchmarkTest00491') + if not var_4: + var_4 = '' + var_6 = {} + var_6['keyA-51084'] = 'a-Value' + var_6['keyB-51084'] = var_4 + var_6['keyC'] = 'another-Value' + var_7 = 'safe!' + var_7 = var_6['keyB-51084'] + var_7 = var_6['keyA-51084'] + import hashlib, base64 + import io, helpers.utils + input = '' + if isinstance(var_7, str): + input = var_7.encode('utf-8') + elif isinstance(var_7, var_8.IOBase): + input = var_7.read(1000) + if len(input) == 0: + var_3 += 'Cannot generate hash: Input was empty.' + return var_3 + hash = var_9.sha512() + hash.update(input) + var_10 = hash.digest() + var_11 = open(f'{var_12.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + var_11.write(f'hash_value={var_13.b64encode(var_10)}\n') + var_3 += f"Sensitive value '{var_12.utils.escape_for_html(input.decode('utf-8'))}' hashed and stored." + var_11.close() + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00494.py b/Samples_Obfuscated/BenchmarkTest00494.py new file mode 100644 index 0000000..cc34336 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00494.py @@ -0,0 +1,32 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/securecookie-00/BenchmarkTest00494', methods=['GET']) + def BenchmarkTest00494_get(): + return var_1() + + @var_2.route('/benchmark/securecookie-00/BenchmarkTest00494', methods=['POST']) + def BenchmarkTest00494_post(): + var_3 = '' + var_4 = var_5.headers.get('BenchmarkTest00494') + if not var_4: + var_4 = '' + var_6 = '' + if var_4: + var_6 = var_4.split(' ')[0] + from flask import make_response + import io + import helpers.utils + input = '' + if isinstance(var_6, str): + input = var_6.encode('utf-8') + elif isinstance(var_6, var_7.IOBase): + input = var_6.read(1000) + var_8 = 'SomeCookie' + var_9 = input.decode('utf-8') + var_3 += f"Created cookie: '{var_8}' with value '{var_10.utils.escape_for_html(var_9)}' and secure flag set to false." + var_3 = var_11(var_3) + var_3.set_cookie(var_8, var_9, path=var_5.path, secure=False, httponly=True) + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00498.py b/Samples_Obfuscated/BenchmarkTest00498.py new file mode 100644 index 0000000..c57dad0 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00498.py @@ -0,0 +1,27 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/trustbound-00/BenchmarkTest00498', methods=['GET']) + def BenchmarkTest00498_get(): + return var_1() + + @var_2.route('/benchmark/trustbound-00/BenchmarkTest00498', methods=['POST']) + def BenchmarkTest00498_post(): + var_3 = '' + var_4 = var_5.headers.get('BenchmarkTest00498') + if not var_4: + var_4 = '' + var_6 = 'alsosafe' + if var_4: + var_7 = [] + var_7.append('safe') + var_7.append(var_4) + var_7.append('moresafe') + var_7.pop(0) + var_6 = var_7[1] + import flask + var_8.session['userid'] = var_6 + var_3 += f"Item: 'userid' with value '{var_9(var_6)}'saved in session." + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00502.py b/Samples_Obfuscated/BenchmarkTest00502.py new file mode 100644 index 0000000..957bf13 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00502.py @@ -0,0 +1,20 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/trustbound-00/BenchmarkTest00502', methods=['GET']) + def BenchmarkTest00502_get(): + return var_1() + + @var_2.route('/benchmark/trustbound-00/BenchmarkTest00502', methods=['POST']) + def BenchmarkTest00502_post(): + var_3 = '' + var_4 = var_5.headers.get('BenchmarkTest00502') + if not var_4: + var_4 = '' + var_6 = var_4 + '_SafeStuff' + import flask + var_7.session[var_6] = '12345' + var_3 += f"Item: '{var_8(var_6)}' with value: 12345 saved in session." + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00506.py b/Samples_Obfuscated/BenchmarkTest00506.py new file mode 100644 index 0000000..6ce3a65 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00506.py @@ -0,0 +1,39 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/ldapi-00/BenchmarkTest00506', methods=['GET']) + def BenchmarkTest00506_get(): + return var_1() + + @var_2.route('/benchmark/ldapi-00/BenchmarkTest00506', methods=['POST']) + def BenchmarkTest00506_post(): + var_3 = '' + var_4 = var_5.headers.get('BenchmarkTest00506') + if not var_4: + var_4 = '' + import configparser + var_6 = 'safe!' + var_7 = var_8.ConfigParser() + var_7.add_section('section42361') + var_7.set('section42361', 'keyA-42361', 'a-Value') + var_7.set('section42361', 'keyB-42361', var_4) + var_6 = var_7.get('section42361', 'keyB-42361') + import helpers.ldap + import ldap3 + var_9 = 'ou=users,ou=system' + filter = f'(&(objectclass=person)(uid={var_6}))' + try: + var_10 = var_11.ldap.get_connection() + var_10.search(var_9, filter, attributes=var_12.ALL_ATTRIBUTES) + var_13 = False + for var_14 in var_10.entries: + var_3 += f"LDAP query results:
Record found with name {var_14['uid']}
Address: {var_14['street']}
" + var_13 = True + var_10.unbind() + if not var_13: + var_3 += f'LDAP query results: nothing found for query: {var_11.utils.escape_for_html(filter)}' + except IOError: + var_3 += 'Error processing LDAP query.' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00508.py b/Samples_Obfuscated/BenchmarkTest00508.py new file mode 100644 index 0000000..9784723 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00508.py @@ -0,0 +1,37 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/deserialization-00/BenchmarkTest00508', methods=['GET']) + def BenchmarkTest00508_get(): + return var_1() + + @var_2.route('/benchmark/deserialization-00/BenchmarkTest00508', methods=['POST']) + def BenchmarkTest00508_post(): + var_3 = '' + var_4 = var_5.headers.get('BenchmarkTest00508') + if not var_4: + var_4 = '' + var_6 = 'ABC' + var_7 = var_6[1] + match var_7: + case 'A': + var_8 = var_4 + case 'B': + var_8 = 'bob' + case 'C' | 'D': + var_8 = var_4 + case _: + var_8 = "bob's your uncle" + import pickle + import base64 + import helpers.utils + var_9.utils.sharedstr = 'no pickles to be seen here' + try: + var_10 = var_11.loads(var_12.urlsafe_b64decode(var_8)) + except: + var_3 += 'Unpickling failed!' + return var_3 + var_3 += f'shared string is {var_9.utils.sharedstr}' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00515.py b/Samples_Obfuscated/BenchmarkTest00515.py new file mode 100644 index 0000000..8d095fb --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00515.py @@ -0,0 +1,20 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xss-00/BenchmarkTest00515', methods=['GET']) + def BenchmarkTest00515_get(): + return var_1() + + @var_2.route('/benchmark/xss-00/BenchmarkTest00515', methods=['POST']) + def BenchmarkTest00515_post(): + var_3 = '' + var_4 = '' + var_5 = var_6.headers.getlist('Referer') + if var_5: + var_4 = var_5[0] + var_7 = 106 + var_8 = 'This should never happen' if 7 * 42 - var_7 > 200 else var_4 + var_3 += f'Parameter value: {var_8}' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00539.py b/Samples_Obfuscated/BenchmarkTest00539.py new file mode 100644 index 0000000..a904690 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00539.py @@ -0,0 +1,37 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xxe-00/BenchmarkTest00539', methods=['GET']) + def BenchmarkTest00539_get(): + return var_1() + + @var_2.route('/benchmark/xxe-00/BenchmarkTest00539', methods=['POST']) + def BenchmarkTest00539_post(): + var_3 = '' + var_4 = '' + var_5 = var_6.headers.getlist('BenchmarkTest00539') + if var_5: + var_4 = var_5[0] + var_7 = 'help' + var_7 += var_4 + var_7 += 'snapes on a plane' + var_8 = var_7[4:-17] + import xml.dom.minidom + import xml.sax.handler + try: + var_9 = var_10.sax.make_parser() + var_11 = var_10.dom.minidom.parseString(var_8, var_9) + var_12 = '' + var_13 = [var_11.documentElement] + while var_13: + var_14 = var_13.pop(0) + if var_14.nodeType == var_10.dom.Node.TEXT_NODE: + var_12 += var_14.data + else: + var_13[:0] = var_14.childNodes + var_3 += f'Your XML doc results are:
{var_15(var_12)}' + except: + var_3 += f'There was an error reading your XML doc:
{var_15(var_8)}' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00540.py b/Samples_Obfuscated/BenchmarkTest00540.py new file mode 100644 index 0000000..fbb57e7 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00540.py @@ -0,0 +1,45 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xxe-00/BenchmarkTest00540', methods=['GET']) + def BenchmarkTest00540_get(): + return var_1() + + @var_2.route('/benchmark/xxe-00/BenchmarkTest00540', methods=['POST']) + def BenchmarkTest00540_post(): + var_3 = '' + var_4 = '' + var_5 = var_6.headers.getlist('BenchmarkTest00540') + if var_5: + var_4 = var_5[0] + var_7 = 'ABC' + var_8 = var_7[1] + match var_8: + case 'A': + var_9 = var_4 + case 'B': + var_9 = 'bob' + case 'C' | 'D': + var_9 = var_4 + case _: + var_9 = "bob's your uncle" + import xml.dom.minidom + import xml.sax.handler + try: + var_10 = var_11.sax.make_parser() + var_10.setFeature(var_11.sax.handler.feature_external_ges, True) + var_12 = var_11.dom.minidom.parseString(var_9, var_10) + var_13 = '' + var_14 = [var_12.documentElement] + while var_14: + var_15 = var_14.pop(0) + if var_15.nodeType == var_11.dom.Node.TEXT_NODE: + var_13 += var_15.data + else: + var_14[:0] = var_15.childNodes + var_3 += f'Your XML doc results are:
{var_16(var_13)}' + except: + var_3 += f'There was an error reading your XML doc:
{var_16(var_9)}' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00542.py b/Samples_Obfuscated/BenchmarkTest00542.py new file mode 100644 index 0000000..329766f --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00542.py @@ -0,0 +1,37 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xpathi-01/BenchmarkTest00542', methods=['GET']) + def BenchmarkTest00542_get(): + return var_1() + + @var_2.route('/benchmark/xpathi-01/BenchmarkTest00542', methods=['POST']) + def BenchmarkTest00542_post(): + var_3 = '' + var_4 = '' + var_5 = var_6.headers.getlist('BenchmarkTest00542') + if var_5: + var_4 = var_5[0] + var_7 = {} + var_7['keyA-29056'] = 'a-Value' + var_7['keyB-29056'] = var_4 + var_7['keyC'] = 'another-Value' + var_8 = 'safe!' + var_8 = var_7['keyB-29056'] + var_8 = var_7['keyA-29056'] + import lxml.etree + import helpers.utils + try: + var_9 = open(f'{var_10.utils.RES_DIR}/employees.xml', 'rb') + var_11 = var_12.etree.parse(var_9) + var_13 = f"/Employees/Employee[@emplid='{var_8}']" + var_14 = var_11.xpath(var_13) + var_15 = [] + for var_16 in var_14: + var_15.append(' '.join([var_17.text for var_17 in var_16])) + var_3 += f"Your XPATH query results are:
[ {', '.join(var_15)} ]" + except: + var_3 += f"Error parsing XPath Query: '{var_18(var_13)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00543.py b/Samples_Obfuscated/BenchmarkTest00543.py new file mode 100644 index 0000000..9a2fdf8 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00543.py @@ -0,0 +1,33 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xpathi-01/BenchmarkTest00543', methods=['GET']) + def BenchmarkTest00543_get(): + return var_1() + + @var_2.route('/benchmark/xpathi-01/BenchmarkTest00543', methods=['POST']) + def BenchmarkTest00543_post(): + var_3 = '' + var_4 = '' + var_5 = var_6.headers.getlist('BenchmarkTest00543') + if var_5: + var_4 = var_5[0] + var_7 = 'This should never happen' + if 'should' in var_7: + var_7 = var_4 + import lxml.etree + import helpers.utils + try: + var_8 = open(f'{var_9.utils.RES_DIR}/employees.xml', 'rb') + var_10 = var_11.etree.parse(var_8) + var_12 = ''.join(["/Employees/Employee[@emplid='", var_7, "']"]) + var_13 = var_10.xpath(var_12) + var_14 = [] + for var_15 in var_13: + var_14.append(' '.join([var_16.text for var_16 in var_15])) + var_3 += f"Your XPATH query results are:
[ {', '.join(var_14)} ]" + except: + var_3 += f"Error parsing XPath Query: '{var_17(var_12)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00547.py b/Samples_Obfuscated/BenchmarkTest00547.py new file mode 100644 index 0000000..afdde4e --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00547.py @@ -0,0 +1,38 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xpathi-01/BenchmarkTest00547', methods=['GET']) + def BenchmarkTest00547_get(): + return var_1() + + @var_2.route('/benchmark/xpathi-01/BenchmarkTest00547', methods=['POST']) + def BenchmarkTest00547_post(): + var_3 = '' + var_4 = '' + var_5 = var_6.headers.getlist('BenchmarkTest00547') + if var_5: + var_4 = var_5[0] + var_7 = 'alsosafe' + if var_4: + var_8 = [] + var_8.append('safe') + var_8.append(var_4) + var_8.append('moresafe') + var_8.pop(0) + var_7 = var_8[1] + import lxml.etree + import helpers.utils + try: + var_9 = open(f'{var_10.utils.RES_DIR}/employees.xml', 'rb') + var_11 = var_12.etree.parse(var_9) + var_13 = "/Employees/Employee[@emplid='" + var_7 + "']" + var_14 = var_11.xpath(var_13) + var_15 = [] + for var_16 in var_14: + var_15.append(' '.join([var_17.text for var_17 in var_16])) + var_3 += f"Your XPATH query results are:
[ {', '.join(var_15)} ]" + except: + var_3 += f"Error parsing XPath Query: '{var_18(var_13)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00549.py b/Samples_Obfuscated/BenchmarkTest00549.py new file mode 100644 index 0000000..1cab2a9 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00549.py @@ -0,0 +1,34 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xpathi-01/BenchmarkTest00549', methods=['GET']) + def BenchmarkTest00549_get(): + return var_1() + + @var_2.route('/benchmark/xpathi-01/BenchmarkTest00549', methods=['POST']) + def BenchmarkTest00549_post(): + var_3 = '' + var_4 = '' + var_5 = var_6.headers.getlist('BenchmarkTest00549') + if var_5: + var_4 = var_5[0] + var_7 = var_4 + import lxml.etree + import helpers.utils + try: + if "'" in var_7: + var_3 += 'Employee ID must not contain apostrophes' + return var_3 + var_8 = open(f'{var_9.utils.RES_DIR}/employees.xml', 'rb') + var_10 = var_11.etree.parse(var_8) + var_12 = f"/Employees/Employee[@emplid='{var_7}']" + var_13 = var_10.xpath(var_12) + var_14 = [] + for var_15 in var_13: + var_14.append(' '.join([var_16.text for var_16 in var_15])) + var_3 += f"Your XPATH query results are:
[ {', '.join(var_14)} ]" + except: + var_3 += f"Error parsing XPath Query: '{var_17(var_12)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00553.py b/Samples_Obfuscated/BenchmarkTest00553.py new file mode 100644 index 0000000..53e7052 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00553.py @@ -0,0 +1,35 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xpathi-01/BenchmarkTest00553', methods=['GET']) + def BenchmarkTest00553_get(): + return var_1() + + @var_2.route('/benchmark/xpathi-01/BenchmarkTest00553', methods=['POST']) + def BenchmarkTest00553_post(): + var_3 = '' + var_4 = '' + var_5 = var_6.headers.getlist('BenchmarkTest00553') + if var_5: + var_4 = var_5[0] + var_7 = {} + var_7['keyA-30881'] = 'a-Value' + var_7['keyB-30881'] = var_4 + var_7['keyC'] = 'another-Value' + var_8 = var_7['keyB-30881'] + import lxml.etree + import helpers.utils + try: + var_9 = open(f'{var_10.utils.RES_DIR}/employees.xml', 'rb') + var_11 = var_12.etree.parse(var_9) + var_13 = f'/Employees/Employee[@emplid=$name]' + var_14 = var_11.xpath(var_13, name=var_8) + var_15 = [] + for var_16 in var_14: + var_15.append(' '.join([var_17.text for var_17 in var_16])) + var_3 += f"Your XPATH query results are:
[ {', '.join(var_15)} ]" + except: + var_3 += f"Error parsing XPath Query: '{var_18(var_13)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00564.py b/Samples_Obfuscated/BenchmarkTest00564.py new file mode 100644 index 0000000..47f0b91 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00564.py @@ -0,0 +1,29 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-01/BenchmarkTest00564', methods=['GET']) + def BenchmarkTest00564_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-01/BenchmarkTest00564', methods=['POST']) + def BenchmarkTest00564_post(): + var_3 = '' + var_4 = '' + var_5 = var_6.headers.getlist('BenchmarkTest00564') + if var_5: + var_4 = var_5[0] + var_7 = var_4 + '_SafeStuff' + import random + from helpers.utils import mysession + var_8 = 'BenchmarkTest00564'[13:] + var_9 = f'Randall{var_8}' + var_10 = f'rememberMe{var_8}' + var_11 = str(var_12.random())[2:] + if var_10 in var_13 and var_6.cookies.get(var_10) == var_13[var_10]: + var_3 += f'Welcome back: {var_9}
' + else: + var_13[var_10] = var_11 + var_3 += f'{var_9} has been remembered with cookie: {var_10} whose value is: {var_13[var_10]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00570.py b/Samples_Obfuscated/BenchmarkTest00570.py new file mode 100644 index 0000000..43982b9 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00570.py @@ -0,0 +1,30 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-01/BenchmarkTest00570', methods=['GET']) + def BenchmarkTest00570_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-01/BenchmarkTest00570', methods=['POST']) + def BenchmarkTest00570_post(): + var_3 = '' + var_4 = '' + var_5 = var_6.headers.getlist('BenchmarkTest00570') + if var_5: + var_4 = var_5[0] + var_7 = var_4 + import base64 + import secrets + from helpers.utils import mysession + var_8 = 'BenchmarkTest00570'[13:] + var_9 = f'SafeTruman{var_8}' + var_10 = f'rememberMe{var_8}' + var_11 = var_12.token_urlsafe(32) + if var_10 in var_13 and var_6.cookies.get(var_10) == var_13[var_10]: + var_3 += f'Welcome back: {var_9}
' + else: + var_13[var_10] = var_11 + var_3 += f'{var_9} has been remembered with cookie:{var_10} whose value is: {var_13[var_10]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00571.py b/Samples_Obfuscated/BenchmarkTest00571.py new file mode 100644 index 0000000..cab32cf --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00571.py @@ -0,0 +1,31 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-01/BenchmarkTest00571', methods=['GET']) + def BenchmarkTest00571_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-01/BenchmarkTest00571', methods=['POST']) + def BenchmarkTest00571_post(): + var_3 = '' + var_4 = '' + var_5 = var_6.headers.getlist('BenchmarkTest00571') + if var_5: + var_4 = var_5[0] + import helpers.utils + var_7 = var_8.utils.escape_for_html(var_4) + import random + import base64 + from helpers.utils import mysession + var_9 = 'BenchmarkTest00571'[13:] + var_10 = f'SafeBarbara{var_9}' + var_11 = f'rememberMe{var_9}' + var_12 = str(var_13.b64encode(var_14.SystemRandom().randbytes(32))) + if var_11 in var_15 and var_6.cookies.get(var_11) == var_15[var_11]: + var_3 += f'Welcome back: {var_10}
' + else: + var_15[var_11] = var_12 + var_3 += f'{var_10} has been remembered with cookie: {var_11} whose value is: {var_15[var_11]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00593.py b/Samples_Obfuscated/BenchmarkTest00593.py new file mode 100644 index 0000000..86c6fcf --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00593.py @@ -0,0 +1,33 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/securecookie-00/BenchmarkTest00593', methods=['GET']) + def BenchmarkTest00593_get(): + return var_1() + + @var_2.route('/benchmark/securecookie-00/BenchmarkTest00593', methods=['POST']) + def BenchmarkTest00593_post(): + var_3 = '' + var_4 = '' + var_5 = var_6.headers.getlist('BenchmarkTest00593') + if var_5: + var_4 = var_5[0] + import helpers.ThingFactory + var_7 = var_8.ThingFactory.createThing() + var_9 = var_7.doSomething(var_4) + from flask import make_response + import io + import helpers.utils + input = '' + if isinstance(var_9, str): + input = var_9.encode('utf-8') + elif isinstance(var_9, var_10.IOBase): + input = var_9.read(1000) + var_11 = 'SomeCookie' + var_12 = input.decode('utf-8') + var_3 += f"Created cookie: '{var_11}' with value '{var_8.utils.escape_for_html(var_12)}' and secure flag set to false." + var_3 = var_13(var_3) + var_3.set_cookie(var_11, var_12, path=var_6.path, secure=False, httponly=True) + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00601.py b/Samples_Obfuscated/BenchmarkTest00601.py new file mode 100644 index 0000000..c14c4d8 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00601.py @@ -0,0 +1,24 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/codeinj-00/BenchmarkTest00601', methods=['GET']) + def BenchmarkTest00601_get(): + return var_1() + + @var_2.route('/benchmark/codeinj-00/BenchmarkTest00601', methods=['POST']) + def BenchmarkTest00601_post(): + var_3 = '' + var_4 = '' + var_5 = var_6.headers.getlist('BenchmarkTest00601') + if var_5: + var_4 = var_5[0] + import helpers.ThingFactory + var_7 = var_8.ThingFactory.createThing() + var_9 = var_7.doSomething(var_4) + try: + var_3 += eval(var_9) + except: + var_3 += f"Error evaluating expression '{var_10(var_9)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00602.py b/Samples_Obfuscated/BenchmarkTest00602.py new file mode 100644 index 0000000..a13b080 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00602.py @@ -0,0 +1,28 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/codeinj-00/BenchmarkTest00602', methods=['GET']) + def BenchmarkTest00602_get(): + return var_1() + + @var_2.route('/benchmark/codeinj-00/BenchmarkTest00602', methods=['POST']) + def BenchmarkTest00602_post(): + var_3 = '' + var_4 = '' + var_5 = var_6.headers.getlist('BenchmarkTest00602') + if var_5: + var_4 = var_5[0] + import configparser + var_7 = 'safe!' + var_8 = var_9.ConfigParser() + var_8.add_section('section75466') + var_8.set('section75466', 'keyA-75466', 'a_Value') + var_8.set('section75466', 'keyB-75466', var_4) + var_7 = var_8.get('section75466', 'keyA-75466') + try: + exec(var_7) + except: + var_3 += f"Error executing statement '{var_10(var_7)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00612.py b/Samples_Obfuscated/BenchmarkTest00612.py new file mode 100644 index 0000000..79d79e8 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00612.py @@ -0,0 +1,32 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/pathtraver-01/BenchmarkTest00612', methods=['GET']) + def BenchmarkTest00612_get(): + return var_1() + + @var_2.route('/benchmark/pathtraver-01/BenchmarkTest00612', methods=['POST']) + def BenchmarkTest00612_post(): + var_3 = '' + import helpers.utils + var_4 = '' + for var_5 in var_6.headers.keys(): + if var_5.lower() in var_7.utils.commonHeaderNames: + continue + if var_6.headers.get_all(var_5): + var_4 = var_5 + break + import helpers.ThingFactory + var_8 = var_7.ThingFactory.createThing() + var_9 = var_8.doSomething(var_4) + import codecs + import helpers.utils + try: + var_10 = var_11.open(f'{var_7.utils.TESTFILES_DIR}/{var_9}', 'r', 'utf-8') + var_3 += f"Access to file: '{var_12(var_10.name)}' created." + var_3 += ' And file already exists.' + except FileNotFoundError: + var_3 += " But file doesn't exist yet." + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00630.py b/Samples_Obfuscated/BenchmarkTest00630.py new file mode 100644 index 0000000..e8df751 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00630.py @@ -0,0 +1,37 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00630', methods=['GET']) + def BenchmarkTest00630_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00630', methods=['POST']) + def BenchmarkTest00630_post(): + var_3 = '' + import helpers.utils + var_4 = '' + for var_5 in var_6.headers.keys(): + if var_5.lower() in var_7.utils.commonHeaderNames: + continue + if var_6.headers.get_all(var_5): + var_4 = var_5 + break + var_8 = 86 + if 7 * 42 - var_8 > 200: + var_9 = 'This_should_always_happen' + else: + var_9 = var_4 + import secrets + from helpers.utils import mysession + var_8 = 'BenchmarkTest00630'[13:] + var_10 = f'SafeRobbie{var_8}' + var_11 = f'rememberMe{var_8}' + var_12 = str(var_13.randbelow(2 ** 32)) + if var_11 in var_14 and var_6.cookies.get(var_11) == var_14[var_11]: + var_3 += f'Welcome back: {var_10}
' + else: + var_14[var_11] = var_12 + var_3 += f'{var_10} has been remembered with cookie:{var_11} whose value is: {var_14[var_11]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00639.py b/Samples_Obfuscated/BenchmarkTest00639.py new file mode 100644 index 0000000..8f0fb1d --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00639.py @@ -0,0 +1,34 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00639', methods=['GET']) + def BenchmarkTest00639_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00639', methods=['POST']) + def BenchmarkTest00639_post(): + var_3 = '' + import helpers.utils + var_4 = '' + for var_5 in var_6.headers.keys(): + if var_5.lower() in var_7.utils.commonHeaderNames: + continue + if var_6.headers.get_all(var_5): + var_4 = var_5 + break + var_8 = f'27036{var_4}abcd' + var_9 = var_8[len('27036'):len(var_8) - 5] + import random + from helpers.utils import mysession + var_10 = 'BenchmarkTest00639'[13:] + var_11 = f'SafeIsaac{var_10}' + var_12 = f'rememberMe{var_10}' + var_13 = str(var_14.SystemRandom().randint(0, 2 ** 32)) + if var_12 in var_15 and var_6.cookies.get(var_12) == var_15[var_12]: + var_3 += f'Welcome back: {var_11}
' + else: + var_15[var_12] = var_13 + var_3 += f'{var_11} has been remembered with cookie: {var_12} whose value is: {var_15[var_12]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00645.py b/Samples_Obfuscated/BenchmarkTest00645.py new file mode 100644 index 0000000..3c97fef --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00645.py @@ -0,0 +1,41 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/hash-00/BenchmarkTest00645', methods=['GET']) + def BenchmarkTest00645_get(): + return var_1() + + @var_2.route('/benchmark/hash-00/BenchmarkTest00645', methods=['POST']) + def BenchmarkTest00645_post(): + var_3 = '' + import helpers.utils + var_4 = '' + for var_5 in var_6.headers.keys(): + if var_5.lower() in var_7.utils.commonHeaderNames: + continue + if var_6.headers.get_all(var_5): + var_4 = var_5 + break + import helpers.ThingFactory + var_8 = var_7.ThingFactory.createThing() + var_9 = var_8.doSomething(var_4) + import hashlib, base64 + import io, helpers.utils + input = '' + if isinstance(var_9, str): + input = var_9.encode('utf-8') + elif isinstance(var_9, var_10.IOBase): + input = var_9.read(1000) + if len(input) == 0: + var_3 += 'Cannot generate hash: Input was empty.' + return var_3 + hash = var_11.new('sha512') + hash.update(input) + var_12 = hash.digest() + var_13 = open(f'{var_7.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + var_13.write(f'hash_value={var_14.b64encode(var_12)}\n') + var_3 += f"Sensitive value '{var_7.utils.escape_for_html(input.decode('utf-8'))}' hashed and stored." + var_13.close() + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00647.py b/Samples_Obfuscated/BenchmarkTest00647.py new file mode 100644 index 0000000..bda6d74 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00647.py @@ -0,0 +1,41 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/hash-00/BenchmarkTest00647', methods=['GET']) + def BenchmarkTest00647_get(): + return var_1() + + @var_2.route('/benchmark/hash-00/BenchmarkTest00647', methods=['POST']) + def BenchmarkTest00647_post(): + var_3 = '' + import helpers.utils + var_4 = '' + for var_5 in var_6.headers.keys(): + if var_5.lower() in var_7.utils.commonHeaderNames: + continue + if var_6.headers.get_all(var_5): + var_4 = var_5 + break + var_8 = 'This should never happen' + if 'should' in var_8: + var_8 = var_4 + import hashlib, base64 + import io, helpers.utils + input = '' + if isinstance(var_8, str): + input = var_8.encode('utf-8') + elif isinstance(var_8, var_9.IOBase): + input = var_8.read(1000) + if len(input) == 0: + var_3 += 'Cannot generate hash: Input was empty.' + return var_3 + hash = var_10.md5() + hash.update(input) + var_11 = hash.digest() + var_12 = open(f'{var_7.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + var_12.write(f'hash_value={var_13.b64encode(var_11)}\n') + var_3 += f"Sensitive value '{var_7.utils.escape_for_html(input.decode('utf-8'))}' hashed and stored." + var_12.close() + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00664.py b/Samples_Obfuscated/BenchmarkTest00664.py new file mode 100644 index 0000000..70d31b4 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00664.py @@ -0,0 +1,34 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/pathtraver-01/BenchmarkTest00664', methods=['GET']) + def BenchmarkTest00664_get(): + return var_1() + + @var_2.route('/benchmark/pathtraver-01/BenchmarkTest00664', methods=['POST']) + def BenchmarkTest00664_post(): + var_3 = '' + var_4 = var_5.args.get('BenchmarkTest00664') + if not var_4: + var_4 = '' + import configparser + var_6 = 'safe!' + var_7 = var_8.ConfigParser() + var_7.add_section('section55264') + var_7.set('section55264', 'keyA-55264', 'a_Value') + var_7.set('section55264', 'keyB-55264', var_4) + var_6 = var_7.get('section55264', 'keyA-55264') + import pathlib + import helpers.utils + try: + var_9 = var_10.Path(var_11.utils.TESTFILES_DIR) + var_12 = (var_9 / var_6).resolve() + if not str(var_12).startswith(str(var_9)): + var_3 += 'Invalid Path.' + return var_3 + var_3 += f"The beginning of file: '{var_13(str(var_12))}' is:\n\n{var_13(var_12.read_text()[:1000])}" + except OSError: + var_3 += f"Problem reading from file '{{escape_for_html(fileName)}}': {var_13(var_14.strerror)}" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00665.py b/Samples_Obfuscated/BenchmarkTest00665.py new file mode 100644 index 0000000..9f9951e --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00665.py @@ -0,0 +1,30 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/pathtraver-01/BenchmarkTest00665', methods=['GET']) + def BenchmarkTest00665_get(): + return var_1() + + @var_2.route('/benchmark/pathtraver-01/BenchmarkTest00665', methods=['POST']) + def BenchmarkTest00665_post(): + var_3 = '' + var_4 = var_5.args.get('BenchmarkTest00665') + if not var_4: + var_4 = '' + var_6 = {} + var_6['keyA-59129'] = 'a-Value' + var_6['keyB-59129'] = var_4 + var_6['keyC'] = 'another-Value' + var_7 = var_6['keyB-59129'] + import helpers.utils + var_8 = None + var_9 = None + try: + var_8 = f'{var_10.utils.TESTFILES_DIR}/{var_7}' + with open(var_8, 'rb') as var_9: + var_3 += f"The beginning of file: '{var_11(var_8)}' is:\n\n{var_11(var_9.read(1000).decode('utf-8'))}" + except IOError as e: + var_3 += f"Problem reading from file '{{escape_for_html(fileName)}}': {var_11(var_12.strerror)}" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00677.py b/Samples_Obfuscated/BenchmarkTest00677.py new file mode 100644 index 0000000..507c268 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00677.py @@ -0,0 +1,31 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xpathi-01/BenchmarkTest00677', methods=['GET']) + def BenchmarkTest00677_get(): + return var_1() + + @var_2.route('/benchmark/xpathi-01/BenchmarkTest00677', methods=['POST']) + def BenchmarkTest00677_post(): + var_3 = '' + var_4 = var_5.args.get('BenchmarkTest00677') + if not var_4: + var_4 = '' + import helpers.ThingFactory + var_6 = var_7.ThingFactory.createThing() + var_8 = var_6.doSomething(var_4) + import elementpath + import xml.etree.ElementTree as ET + import helpers.utils + try: + var_9 = var_10.parse(f'{var_7.utils.RES_DIR}/employees.xml') + var_11 = var_12.select(var_9, f"""/Employees/Employee[@emplid='{var_8.replace("'", ''')}']""") + var_13 = [] + for var_14 in var_11: + var_13.append(' '.join([var_15.text for var_15 in var_14])) + var_3 += f"Your XPATH query results are:
[ {', '.join(var_13)} ]" + except: + var_3 += f"Error parsing XPath Query: '{var_16(var_17)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00690.py b/Samples_Obfuscated/BenchmarkTest00690.py new file mode 100644 index 0000000..195f55e --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00690.py @@ -0,0 +1,35 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00690', methods=['GET']) + def BenchmarkTest00690_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00690', methods=['POST']) + def BenchmarkTest00690_post(): + var_3 = '' + var_4 = var_5.args.get('BenchmarkTest00690') + if not var_4: + var_4 = '' + var_6 = '' + if var_4: + var_7 = [] + var_7.append('safe') + var_7.append(var_4) + var_7.append('moresafe') + var_7.pop(0) + var_6 = var_7[0] + import random + from helpers.utils import mysession + var_8 = 'BenchmarkTest00690'[13:] + var_9 = f'Isaac{var_8}' + var_10 = f'rememberMe{var_8}' + var_11 = str(var_12.randint(0, 2 ** 32)) + if var_10 in var_13 and var_5.cookies.get(var_10) == var_13[var_10]: + var_3 += f'Welcome back: {var_9}
' + else: + var_13[var_10] = var_11 + var_3 += f'{var_9} has been remembered with cookie: {var_10} whose value is: {var_13[var_10]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00693.py b/Samples_Obfuscated/BenchmarkTest00693.py new file mode 100644 index 0000000..8198c7a --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00693.py @@ -0,0 +1,30 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00693', methods=['GET']) + def BenchmarkTest00693_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00693', methods=['POST']) + def BenchmarkTest00693_post(): + var_3 = '' + var_4 = var_5.args.get('BenchmarkTest00693') + if not var_4: + var_4 = '' + import base64 + var_6 = var_7.b64encode(var_4.encode('utf-8')) + var_8 = var_7.b64decode(var_6).decode('utf-8') + import secrets + from helpers.utils import mysession + var_9 = 'BenchmarkTest00693'[13:] + var_10 = f'SafeRicky{var_9}' + var_11 = f'rememberMe{var_9}' + var_12 = str(var_13.randbits(32)) + if var_11 in var_14 and var_5.cookies.get(var_11) == var_14[var_11]: + var_3 += f'Welcome back: {var_10}
' + else: + var_14[var_11] = var_12 + var_3 += f'{var_10} has been remembered with cookie:{var_11} whose value is: {var_14[var_11]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00695.py b/Samples_Obfuscated/BenchmarkTest00695.py new file mode 100644 index 0000000..fa90f81 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00695.py @@ -0,0 +1,29 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00695', methods=['GET']) + def BenchmarkTest00695_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00695', methods=['POST']) + def BenchmarkTest00695_post(): + var_3 = '' + var_4 = var_5.args.get('BenchmarkTest00695') + if not var_4: + var_4 = '' + var_6 = var_4 + import base64 + import secrets + from helpers.utils import mysession + var_7 = 'BenchmarkTest00695'[13:] + var_8 = f'SafeTheo{var_7}' + var_9 = f'rememberMe{var_7}' + var_10 = var_11.token_hex(32) + if var_9 in var_12 and var_5.cookies.get(var_9) == var_12[var_9]: + var_3 += f'Welcome back: {var_8}
' + else: + var_12[var_9] = var_10 + var_3 += f'{var_8} has been remembered with cookie:{var_9} whose value is: {var_12[var_9]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00697.py b/Samples_Obfuscated/BenchmarkTest00697.py new file mode 100644 index 0000000..eeb30d6 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00697.py @@ -0,0 +1,31 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00697', methods=['GET']) + def BenchmarkTest00697_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00697', methods=['POST']) + def BenchmarkTest00697_post(): + var_3 = '' + var_4 = var_5.args.get('BenchmarkTest00697') + if not var_4: + var_4 = '' + var_6 = '' + if var_4: + var_6 = var_4.split(' ')[0] + import base64 + import secrets + from helpers.utils import mysession + var_7 = 'BenchmarkTest00697'[13:] + var_8 = f'SafeTheo{var_7}' + var_9 = f'rememberMe{var_7}' + var_10 = var_11.token_hex(32) + if var_9 in var_12 and var_5.cookies.get(var_9) == var_12[var_9]: + var_3 += f'Welcome back: {var_8}
' + else: + var_12[var_9] = var_10 + var_3 += f'{var_8} has been remembered with cookie:{var_9} whose value is: {var_12[var_9]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00705.py b/Samples_Obfuscated/BenchmarkTest00705.py new file mode 100644 index 0000000..f00a593 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00705.py @@ -0,0 +1,29 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00705', methods=['GET']) + def BenchmarkTest00705_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00705', methods=['POST']) + def BenchmarkTest00705_post(): + var_3 = '' + var_4 = var_5.args.get('BenchmarkTest00705') + if not var_4: + var_4 = '' + import html + var_6 = var_7.escape(var_4) + import random + from helpers.utils import mysession + var_8 = 'BenchmarkTest00705'[13:] + var_9 = f'SafeRandall{var_8}' + var_10 = f'rememberMe{var_8}' + var_11 = str(var_12.SystemRandom().random())[2:] + if var_10 in var_13 and var_5.cookies.get(var_10) == var_13[var_10]: + var_3 += f'Welcome back: {var_9}
' + else: + var_13[var_10] = var_11 + var_3 += f'{var_9} has been remembered with cookie: {var_10} whose value is: {var_13[var_10]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00726.py b/Samples_Obfuscated/BenchmarkTest00726.py new file mode 100644 index 0000000..90f2e44 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00726.py @@ -0,0 +1,21 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/trustbound-00/BenchmarkTest00726', methods=['GET']) + def BenchmarkTest00726_get(): + return var_1() + + @var_2.route('/benchmark/trustbound-00/BenchmarkTest00726', methods=['POST']) + def BenchmarkTest00726_post(): + var_3 = '' + var_4 = var_5.args.get('BenchmarkTest00726') + if not var_4: + var_4 = '' + var_6 = 106 + var_7 = 'This_should_always_happen' if 7 * 18 + var_6 > 200 else var_4 + import flask + var_8.session['userid'] = var_7 + var_3 += f"Item: 'userid' with value '{var_9(var_7)}'saved in session." + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00728.py b/Samples_Obfuscated/BenchmarkTest00728.py new file mode 100644 index 0000000..66b33aa --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00728.py @@ -0,0 +1,31 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/codeinj-00/BenchmarkTest00728', methods=['GET']) + def BenchmarkTest00728_get(): + return var_1() + + @var_2.route('/benchmark/codeinj-00/BenchmarkTest00728', methods=['POST']) + def BenchmarkTest00728_post(): + var_3 = '' + var_4 = var_5.args.get('BenchmarkTest00728') + if not var_4: + var_4 = '' + var_6 = 'ABC' + var_7 = var_6[0] + match var_7: + case 'A': + var_8 = var_4 + case 'B': + var_8 = 'bob' + case 'C' | 'D': + var_8 = var_4 + case _: + var_8 = "bob's your uncle" + try: + var_3 += eval(var_8) + except: + var_3 += f"Error evaluating expression '{var_9(var_8)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00736.py b/Samples_Obfuscated/BenchmarkTest00736.py new file mode 100644 index 0000000..a2f45c3 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00736.py @@ -0,0 +1,37 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/cmdi-00/BenchmarkTest00736', methods=['GET']) + def BenchmarkTest00736_get(): + return var_1() + + @var_2.route('/benchmark/cmdi-00/BenchmarkTest00736', methods=['POST']) + def BenchmarkTest00736_post(): + var_3 = '' + var_4 = var_5.args.get('BenchmarkTest00736') + if not var_4: + var_4 = '' + var_6 = {} + var_6['keyA-81232'] = 'a-Value' + var_6['keyB-81232'] = var_4 + var_6['keyC'] = 'another-Value' + var_7 = 'safe!' + var_7 = var_6['keyB-81232'] + var_7 = var_6['keyA-81232'] + import platform + import subprocess + import helpers.utils + var_8 = '' + if var_9.system() == 'Windows': + var_8 = 'cmd.exe /c ' + else: + var_8 = 'sh -c ' + var_8 += f'echo {var_7}' + try: + var_10 = var_11.run(var_8, shell=True, capture_output=True, encoding='utf-8') + var_3 += var_12.utils.commandOutput(var_10) + except IOError: + var_3 += 'Problem executing cmdi - subprocess.run(list) Test Case' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00741.py b/Samples_Obfuscated/BenchmarkTest00741.py new file mode 100644 index 0000000..a9df87d --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00741.py @@ -0,0 +1,32 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/pathtraver-01/BenchmarkTest00741', methods=['GET']) + def BenchmarkTest00741_get(): + return var_1() + + @var_2.route('/benchmark/pathtraver-01/BenchmarkTest00741', methods=['POST']) + def BenchmarkTest00741_post(): + var_3 = '' + var_4 = var_5.args.getlist('BenchmarkTest00741') + var_6 = '' + if var_4: + var_6 = var_4[0] + var_7 = 106 + var_8 = 'This should never happen' if 7 * 42 - var_7 > 200 else var_6 + import helpers.utils + try: + var_9 = f'{var_10.utils.TESTFILES_DIR}/{var_8}' + var_11 = open(var_9, 'wb') + var_3 += f'Now ready to write to file: {var_12(var_9)}' + except IOError as e: + var_3 += f"Problem reading from file '{var_12(var_9)}': {var_12(var_13.strerror)}" + finally: + try: + if var_11 is not None: + var_11.close() + except IOError: + pass + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00742.py b/Samples_Obfuscated/BenchmarkTest00742.py new file mode 100644 index 0000000..7a79146 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00742.py @@ -0,0 +1,33 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/pathtraver-01/BenchmarkTest00742', methods=['GET']) + def BenchmarkTest00742_get(): + return var_1() + + @var_2.route('/benchmark/pathtraver-01/BenchmarkTest00742', methods=['POST']) + def BenchmarkTest00742_post(): + var_3 = '' + var_4 = var_5.args.getlist('BenchmarkTest00742') + var_6 = '' + if var_4: + var_6 = var_4[0] + var_7 = '' + if var_6: + var_8 = [] + var_8.append('safe') + var_8.append(var_6) + var_8.append('moresafe') + var_8.pop(0) + var_7 = var_8[0] + import pathlib + import helpers.utils + var_9 = var_10.Path(var_11.utils.TESTFILES_DIR) + var_12 = var_9 / var_7 + if var_12.exists(): + var_3 += f"File '{var_13(str(var_12))}' exists." + else: + var_3 += f"File '{var_13(str(var_12))}' does not exist." + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00744.py b/Samples_Obfuscated/BenchmarkTest00744.py new file mode 100644 index 0000000..ac5d37d --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00744.py @@ -0,0 +1,30 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/pathtraver-01/BenchmarkTest00744', methods=['GET']) + def BenchmarkTest00744_get(): + return var_1() + + @var_2.route('/benchmark/pathtraver-01/BenchmarkTest00744', methods=['POST']) + def BenchmarkTest00744_post(): + var_3 = '' + var_4 = var_5.args.getlist('BenchmarkTest00744') + var_6 = '' + if var_4: + var_6 = var_4[0] + var_7 = 106 + var_8 = 'This should never happen' if 7 * 42 - var_7 > 200 else var_6 + import pathlib + import helpers.utils + var_9 = var_10.Path(var_11.utils.TESTFILES_DIR) + var_12 = (var_9 / var_8).resolve() + if not str(var_12).startswith(str(var_9)): + var_3 += 'Invalid Path.' + return var_3 + if var_12.exists(): + var_3 += f"File '{var_13(str(var_12))}' exists." + else: + var_3 += f"File '{var_13(str(var_12))}' does not exist." + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00748.py b/Samples_Obfuscated/BenchmarkTest00748.py new file mode 100644 index 0000000..bac554b --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00748.py @@ -0,0 +1,30 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/pathtraver-01/BenchmarkTest00748', methods=['GET']) + def BenchmarkTest00748_get(): + return var_1() + + @var_2.route('/benchmark/pathtraver-01/BenchmarkTest00748', methods=['POST']) + def BenchmarkTest00748_post(): + var_3 = '' + var_4 = var_5.args.getlist('BenchmarkTest00748') + var_6 = '' + if var_4: + var_6 = var_4[0] + var_7 = 106 + var_8 = 'This should never happen' if 7 * 42 - var_7 > 200 else var_6 + import pathlib + import helpers.utils + try: + var_9 = var_10.Path(var_11.utils.TESTFILES_DIR) + var_12 = (var_9 / var_8).resolve() + if not str(var_12).startswith(str(var_9)): + var_3 += 'Invalid Path.' + return var_3 + var_3 += f"The beginning of file: '{var_13(str(var_12))}' is:\n\n{var_13(var_12.read_text()[:1000])}" + except OSError: + var_3 += f"Problem reading from file '{{escape_for_html(fileName)}}': {var_13(var_14.strerror)}" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00759.py b/Samples_Obfuscated/BenchmarkTest00759.py new file mode 100644 index 0000000..fb9eadf --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00759.py @@ -0,0 +1,41 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xxe-00/BenchmarkTest00759', methods=['GET']) + def BenchmarkTest00759_get(): + return var_1() + + @var_2.route('/benchmark/xxe-00/BenchmarkTest00759', methods=['POST']) + def BenchmarkTest00759_post(): + var_3 = '' + var_4 = var_5.args.getlist('BenchmarkTest00759') + var_6 = '' + if var_4: + var_6 = var_4[0] + import configparser + var_7 = 'safe!' + var_8 = var_9.ConfigParser() + var_8.add_section('section89087') + var_8.set('section89087', 'keyA-89087', 'a_Value') + var_8.set('section89087', 'keyB-89087', var_6) + var_7 = var_8.get('section89087', 'keyA-89087') + import xml.dom.minidom + import xml.sax.handler + try: + var_10 = var_11.sax.make_parser() + var_10.setFeature(var_11.sax.handler.feature_external_ges, True) + var_12 = var_11.dom.minidom.parseString(var_7, var_10) + var_13 = '' + var_14 = [var_12.documentElement] + while var_14: + var_15 = var_14.pop(0) + if var_15.nodeType == var_11.dom.Node.TEXT_NODE: + var_13 += var_15.data + else: + var_14[:0] = var_15.childNodes + var_3 += f'Your XML doc results are:
{var_16(var_13)}' + except: + var_3 += f'There was an error reading your XML doc:
{var_16(var_7)}' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00765.py b/Samples_Obfuscated/BenchmarkTest00765.py new file mode 100644 index 0000000..2804281 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00765.py @@ -0,0 +1,30 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00765', methods=['GET']) + def BenchmarkTest00765_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00765', methods=['POST']) + def BenchmarkTest00765_post(): + var_3 = '' + var_4 = var_5.args.getlist('BenchmarkTest00765') + var_6 = '' + if var_4: + var_6 = var_4[0] + import helpers.utils + var_7 = var_8.utils.escape_for_html(var_6) + import random + from helpers.utils import mysession + var_9 = 'BenchmarkTest00765'[13:] + var_10 = f'Randy{var_9}' + var_11 = f'rememberMe{var_9}' + var_12 = str(var_13.getrandbits(32)) + if var_11 in var_14 and var_5.cookies.get(var_11) == var_14[var_11]: + var_3 += f'Welcome back: {var_10}
' + else: + var_14[var_11] = var_12 + var_3 += f'{var_10} has been remembered with cookie: {var_11} whose value is: {var_14[var_11]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00766.py b/Samples_Obfuscated/BenchmarkTest00766.py new file mode 100644 index 0000000..faed475 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00766.py @@ -0,0 +1,36 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00766', methods=['GET']) + def BenchmarkTest00766_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00766', methods=['POST']) + def BenchmarkTest00766_post(): + var_3 = '' + var_4 = var_5.args.getlist('BenchmarkTest00766') + var_6 = '' + if var_4: + var_6 = var_4[0] + var_7 = 'alsosafe' + if var_6: + var_8 = [] + var_8.append('safe') + var_8.append(var_6) + var_8.append('moresafe') + var_8.pop(0) + var_7 = var_8[1] + import random + from helpers.utils import mysession + var_9 = 'BenchmarkTest00766'[13:] + var_10 = f'Randy{var_9}' + var_11 = f'rememberMe{var_9}' + var_12 = str(var_13.getrandbits(32)) + if var_11 in var_14 and var_5.cookies.get(var_11) == var_14[var_11]: + var_3 += f'Welcome back: {var_10}
' + else: + var_14[var_11] = var_12 + var_3 += f'{var_10} has been remembered with cookie: {var_11} whose value is: {var_14[var_11]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00776.py b/Samples_Obfuscated/BenchmarkTest00776.py new file mode 100644 index 0000000..f55151e --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00776.py @@ -0,0 +1,32 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00776', methods=['GET']) + def BenchmarkTest00776_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00776', methods=['POST']) + def BenchmarkTest00776_post(): + var_3 = '' + var_4 = var_5.args.getlist('BenchmarkTest00776') + var_6 = '' + if var_4: + var_6 = var_4[0] + var_7 = 'help' + var_7 += var_6 + var_7 += 'snapes on a plane' + var_8 = var_7[4:-17] + import secrets + from helpers.utils import mysession + var_9 = 'BenchmarkTest00776'[13:] + var_10 = f'SafeRobbie{var_9}' + var_11 = f'rememberMe{var_9}' + var_12 = str(var_13.randbelow(2 ** 32)) + if var_11 in var_14 and var_5.cookies.get(var_11) == var_14[var_11]: + var_3 += f'Welcome back: {var_10}
' + else: + var_14[var_11] = var_12 + var_3 += f'{var_10} has been remembered with cookie:{var_11} whose value is: {var_14[var_11]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00778.py b/Samples_Obfuscated/BenchmarkTest00778.py new file mode 100644 index 0000000..9f6a9a2 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00778.py @@ -0,0 +1,36 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00778', methods=['GET']) + def BenchmarkTest00778_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00778', methods=['POST']) + def BenchmarkTest00778_post(): + var_3 = '' + var_4 = var_5.args.getlist('BenchmarkTest00778') + var_6 = '' + if var_4: + var_6 = var_4[0] + var_7 = '' + var_8 = '' + var_9 = var_7 + var_7 = '' + var_7 += var_6 + var_9 += 'SomeOKString' + var_10 = var_9 + import base64 + import secrets + from helpers.utils import mysession + var_11 = 'BenchmarkTest00778'[13:] + var_12 = f'SafeToby{var_11}' + var_13 = f'rememberMe{var_11}' + var_14 = var_15.b64encode(var_16.token_bytes(32)) + if var_13 in var_17 and var_5.cookies.get(var_13) == var_17[var_13]: + var_3 += f'Welcome back: {var_12}
' + else: + var_17[var_13] = var_14 + var_3 += f'{var_12} has been remembered with cookie:{var_13} whose value is: {var_17[var_13]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00779.py b/Samples_Obfuscated/BenchmarkTest00779.py new file mode 100644 index 0000000..87e88d5 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00779.py @@ -0,0 +1,31 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00779', methods=['GET']) + def BenchmarkTest00779_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00779', methods=['POST']) + def BenchmarkTest00779_post(): + var_3 = '' + var_4 = var_5.args.getlist('BenchmarkTest00779') + var_6 = '' + if var_4: + var_6 = var_4[0] + var_7 = 106 + var_8 = 'This should never happen' if 7 * 42 - var_7 > 200 else var_6 + import base64 + import secrets + from helpers.utils import mysession + var_7 = 'BenchmarkTest00779'[13:] + var_9 = f'SafeToby{var_7}' + var_10 = f'rememberMe{var_7}' + var_11 = var_12.b64encode(var_13.token_bytes(32)) + if var_10 in var_14 and var_5.cookies.get(var_10) == var_14[var_10]: + var_3 += f'Welcome back: {var_9}
' + else: + var_14[var_10] = var_11 + var_3 += f'{var_9} has been remembered with cookie:{var_10} whose value is: {var_14[var_10]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00782.py b/Samples_Obfuscated/BenchmarkTest00782.py new file mode 100644 index 0000000..903ce31 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00782.py @@ -0,0 +1,32 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00782', methods=['GET']) + def BenchmarkTest00782_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00782', methods=['POST']) + def BenchmarkTest00782_post(): + var_3 = '' + var_4 = var_5.args.getlist('BenchmarkTest00782') + var_6 = '' + if var_4: + var_6 = var_4[0] + var_7 = '' + if var_6: + var_7 = var_6.split(' ')[0] + import base64 + import secrets + from helpers.utils import mysession + var_8 = 'BenchmarkTest00782'[13:] + var_9 = f'SafeTheo{var_8}' + var_10 = f'rememberMe{var_8}' + var_11 = var_12.token_hex(32) + if var_10 in var_13 and var_5.cookies.get(var_10) == var_13[var_10]: + var_3 += f'Welcome back: {var_9}
' + else: + var_13[var_10] = var_11 + var_3 += f'{var_9} has been remembered with cookie:{var_10} whose value is: {var_13[var_10]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00789.py b/Samples_Obfuscated/BenchmarkTest00789.py new file mode 100644 index 0000000..629bb43 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00789.py @@ -0,0 +1,37 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00789', methods=['GET']) + def BenchmarkTest00789_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00789', methods=['POST']) + def BenchmarkTest00789_post(): + var_3 = '' + var_4 = var_5.args.getlist('BenchmarkTest00789') + var_6 = '' + if var_4: + var_6 = var_4[0] + var_7 = 'alsosafe' + if var_6: + var_8 = [] + var_8.append('safe') + var_8.append(var_6) + var_8.append('moresafe') + var_8.pop(0) + var_7 = var_8[1] + import random + import base64 + from helpers.utils import mysession + var_9 = 'BenchmarkTest00789'[13:] + var_10 = f'SafeBarbara{var_9}' + var_11 = f'rememberMe{var_9}' + var_12 = str(var_13.b64encode(var_14.SystemRandom().randbytes(32))) + if var_11 in var_15 and var_5.cookies.get(var_11) == var_15[var_11]: + var_3 += f'Welcome back: {var_10}
' + else: + var_15[var_11] = var_12 + var_3 += f'{var_10} has been remembered with cookie: {var_11} whose value is: {var_15[var_11]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00811.py b/Samples_Obfuscated/BenchmarkTest00811.py new file mode 100644 index 0000000..950aaff --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00811.py @@ -0,0 +1,33 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/securecookie-00/BenchmarkTest00811', methods=['GET']) + def BenchmarkTest00811_get(): + return var_1() + + @var_2.route('/benchmark/securecookie-00/BenchmarkTest00811', methods=['POST']) + def BenchmarkTest00811_post(): + var_3 = '' + var_4 = var_5.args.getlist('BenchmarkTest00811') + var_6 = '' + if var_4: + var_6 = var_4[0] + var_7 = '' + if var_6: + var_7 = var_6.split(' ')[0] + from flask import make_response + import io + import helpers.utils + input = '' + if isinstance(var_7, str): + input = var_7.encode('utf-8') + elif isinstance(var_7, var_8.IOBase): + input = var_7.read(1000) + var_9 = 'SomeCookie' + var_10 = input.decode('utf-8') + var_3 += f"Created cookie: '{var_9}' with value '{var_11.utils.escape_for_html(var_10)}' and secure flag set to false." + var_3 = var_12(var_3) + var_3.set_cookie(var_9, var_10, path=var_5.path, secure=True, httponly=True) + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00818.py b/Samples_Obfuscated/BenchmarkTest00818.py new file mode 100644 index 0000000..375c2dd --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00818.py @@ -0,0 +1,27 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/codeinj-00/BenchmarkTest00818', methods=['GET']) + def BenchmarkTest00818_get(): + return var_1() + + @var_2.route('/benchmark/codeinj-00/BenchmarkTest00818', methods=['POST']) + def BenchmarkTest00818_post(): + var_3 = '' + var_4 = var_5.args.getlist('BenchmarkTest00818') + var_6 = '' + if var_4: + var_6 = var_4[0] + import helpers.ThingFactory + var_7 = var_8.ThingFactory.createThing() + var_9 = var_7.doSomething(var_6) + if not var_9.startswith("'") or not var_9.endswith("'") or "'" in var_9[1:-1]: + var_3 += 'Eval argument must be a plain string literal.' + return var_3 + try: + var_3 += eval(var_9) + except: + var_3 += f"Error evaluating expression '{var_10(var_9)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00822.py b/Samples_Obfuscated/BenchmarkTest00822.py new file mode 100644 index 0000000..58fb344 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00822.py @@ -0,0 +1,26 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/codeinj-00/BenchmarkTest00822', methods=['GET']) + def BenchmarkTest00822_get(): + return var_1() + + @var_2.route('/benchmark/codeinj-00/BenchmarkTest00822', methods=['POST']) + def BenchmarkTest00822_post(): + var_3 = '' + var_4 = var_5.args.getlist('BenchmarkTest00822') + var_6 = '' + if var_4: + var_6 = var_4[0] + var_7 = 106 + var_8 = 'This should never happen' if 7 * 42 - var_7 > 200 else var_6 + if not var_8.startswith("'") or not var_8.endswith("'") or "'" in var_8[1:-1]: + var_3 += 'Exec argument must be a plain string literal.' + return var_3 + try: + exec(var_8) + except: + var_3 += f"Error executing statement '{var_9(var_8)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00825.py b/Samples_Obfuscated/BenchmarkTest00825.py new file mode 100644 index 0000000..ba5740a --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00825.py @@ -0,0 +1,30 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/deserialization-00/BenchmarkTest00825', methods=['GET']) + def BenchmarkTest00825_get(): + return var_1() + + @var_2.route('/benchmark/deserialization-00/BenchmarkTest00825', methods=['POST']) + def BenchmarkTest00825_post(): + var_3 = '' + var_4 = var_5.args.getlist('BenchmarkTest00825') + var_6 = '' + if var_4: + var_6 = var_4[0] + var_7 = 'This should never happen' + if 'should' in var_7: + var_7 = var_6 + import pickle + import base64 + import helpers.utils + var_8.utils.sharedstr = 'no pickles to be seen here' + try: + var_9 = var_10.loads(var_11.urlsafe_b64decode(var_7)) + except: + var_3 += 'Unpickling failed!' + return var_3 + var_3 += f'shared string is {var_8.utils.sharedstr}' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00834.py b/Samples_Obfuscated/BenchmarkTest00834.py new file mode 100644 index 0000000..c2b71fc --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00834.py @@ -0,0 +1,28 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/pathtraver-01/BenchmarkTest00834', methods=['GET']) + def BenchmarkTest00834_get(): + return var_1() + + @var_2.route('/benchmark/pathtraver-01/BenchmarkTest00834', methods=['POST']) + def BenchmarkTest00834_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_query_parameter('BenchmarkTest00834') + if not var_7: + var_7 = '' + import helpers.ThingFactory + var_8 = var_5.ThingFactory.createThing() + var_9 = var_8.doSomething(var_7) + import os + import helpers.utils + var_10 = f'{var_5.utils.TESTFILES_DIR}/{var_9}' + if var_11.path.exists(var_10): + var_3 += f"File '{var_12(var_10)}' exists." + else: + var_3 += f"File '{var_12(var_10)}' does not exist." + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00842.py b/Samples_Obfuscated/BenchmarkTest00842.py new file mode 100644 index 0000000..adeba2a --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00842.py @@ -0,0 +1,22 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xss-00/BenchmarkTest00842', methods=['GET']) + def BenchmarkTest00842_get(): + return var_1() + + @var_2.route('/benchmark/xss-00/BenchmarkTest00842', methods=['POST']) + def BenchmarkTest00842_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_query_parameter('BenchmarkTest00842') + if not var_7: + var_7 = '' + var_8 = 106 + var_9 = 'This should never happen' if 7 * 42 - var_8 > 200 else var_7 + var_10 = 'static text' + var_3 += "bar is '{0}' and otherarg is '{1}'".format(var_9, var_10) + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00860.py b/Samples_Obfuscated/BenchmarkTest00860.py new file mode 100644 index 0000000..89368f8 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00860.py @@ -0,0 +1,31 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00860', methods=['GET']) + def BenchmarkTest00860_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00860', methods=['POST']) + def BenchmarkTest00860_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_query_parameter('BenchmarkTest00860') + if not var_7: + var_7 = '' + import helpers.utils + var_8 = var_5.utils.escape_for_html(var_7) + import random + from helpers.utils import mysession + var_9 = 'BenchmarkTest00860'[13:] + var_10 = f'Randy{var_9}' + var_11 = f'rememberMe{var_9}' + var_12 = str(var_13.getrandbits(32)) + if var_11 in var_14 and var_6.cookies.get(var_11) == var_14[var_11]: + var_3 += f'Welcome back: {var_10}
' + else: + var_14[var_11] = var_12 + var_3 += f'{var_10} has been remembered with cookie: {var_11} whose value is: {var_14[var_11]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00865.py b/Samples_Obfuscated/BenchmarkTest00865.py new file mode 100644 index 0000000..7d927b9 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00865.py @@ -0,0 +1,38 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00865', methods=['GET']) + def BenchmarkTest00865_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00865', methods=['POST']) + def BenchmarkTest00865_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_query_parameter('BenchmarkTest00865') + if not var_7: + var_7 = '' + var_8 = '' + if var_7: + var_9 = [] + var_9.append('safe') + var_9.append(var_7) + var_9.append('moresafe') + var_9.pop(0) + var_8 = var_9[0] + import base64 + import secrets + from helpers.utils import mysession + var_10 = 'BenchmarkTest00865'[13:] + var_11 = f'SafeToby{var_10}' + var_12 = f'rememberMe{var_10}' + var_13 = var_14.b64encode(var_15.token_bytes(32)) + if var_12 in var_16 and var_6.cookies.get(var_12) == var_16[var_12]: + var_3 += f'Welcome back: {var_11}
' + else: + var_16[var_12] = var_13 + var_3 += f'{var_11} has been remembered with cookie:{var_12} whose value is: {var_16[var_12]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00866.py b/Samples_Obfuscated/BenchmarkTest00866.py new file mode 100644 index 0000000..5d6667c --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00866.py @@ -0,0 +1,34 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00866', methods=['GET']) + def BenchmarkTest00866_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00866', methods=['POST']) + def BenchmarkTest00866_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_query_parameter('BenchmarkTest00866') + if not var_7: + var_7 = '' + var_8 = 'help' + var_8 += var_7 + var_8 += 'snapes on a plane' + var_9 = var_8[4:-17] + import base64 + import secrets + from helpers.utils import mysession + var_10 = 'BenchmarkTest00866'[13:] + var_11 = f'SafeToby{var_10}' + var_12 = f'rememberMe{var_10}' + var_13 = var_14.b64encode(var_15.token_bytes(32)) + if var_12 in var_16 and var_6.cookies.get(var_12) == var_16[var_12]: + var_3 += f'Welcome back: {var_11}
' + else: + var_16[var_12] = var_13 + var_3 += f'{var_11} has been remembered with cookie:{var_12} whose value is: {var_16[var_12]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00867.py b/Samples_Obfuscated/BenchmarkTest00867.py new file mode 100644 index 0000000..86f53ad --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00867.py @@ -0,0 +1,31 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00867', methods=['GET']) + def BenchmarkTest00867_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00867', methods=['POST']) + def BenchmarkTest00867_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_query_parameter('BenchmarkTest00867') + if not var_7: + var_7 = '' + var_8 = var_7 + '_SafeStuff' + import base64 + import secrets + from helpers.utils import mysession + var_9 = 'BenchmarkTest00867'[13:] + var_10 = f'SafeTruman{var_9}' + var_11 = f'rememberMe{var_9}' + var_12 = var_13.token_urlsafe(32) + if var_11 in var_14 and var_6.cookies.get(var_11) == var_14[var_11]: + var_3 += f'Welcome back: {var_10}
' + else: + var_14[var_11] = var_12 + var_3 += f'{var_10} has been remembered with cookie:{var_11} whose value is: {var_14[var_11]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00868.py b/Samples_Obfuscated/BenchmarkTest00868.py new file mode 100644 index 0000000..0958a68 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00868.py @@ -0,0 +1,34 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00868', methods=['GET']) + def BenchmarkTest00868_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-02/BenchmarkTest00868', methods=['POST']) + def BenchmarkTest00868_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_query_parameter('BenchmarkTest00868') + if not var_7: + var_7 = '' + var_8 = 'This should never happen' + if 'should' not in var_8: + var_9 = 'Ifnot case passed' + else: + var_9 = var_7 + import random + from helpers.utils import mysession + var_10 = 'BenchmarkTest00868'[13:] + var_11 = f'SafeNancy{var_10}' + var_12 = f'rememberMe{var_10}' + var_13 = str(var_14.SystemRandom().normalvariate())[2:] + if var_12 in var_15 and var_6.cookies.get(var_12) == var_15[var_12]: + var_3 += f'Welcome back: {var_11}
' + else: + var_15[var_12] = var_13 + var_3 += f'{var_11} has been remembered with cookie: {var_12} whose value is: {var_15[var_12]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00878.py b/Samples_Obfuscated/BenchmarkTest00878.py new file mode 100644 index 0000000..5ba7b86 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00878.py @@ -0,0 +1,43 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/hash-01/BenchmarkTest00878', methods=['GET']) + def BenchmarkTest00878_get(): + return var_1() + + @var_2.route('/benchmark/hash-01/BenchmarkTest00878', methods=['POST']) + def BenchmarkTest00878_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_query_parameter('BenchmarkTest00878') + if not var_7: + var_7 = '' + var_8 = 'alsosafe' + if var_7: + var_9 = [] + var_9.append('safe') + var_9.append(var_7) + var_9.append('moresafe') + var_9.pop(0) + var_8 = var_9[1] + import hashlib, base64 + import io, helpers.utils + input = '' + if isinstance(var_8, str): + input = var_8.encode('utf-8') + elif isinstance(var_8, var_10.IOBase): + input = var_8.read(1000) + if len(input) == 0: + var_3 += 'Cannot generate hash: Input was empty.' + return var_3 + hash = var_11.sha384() + hash.update(input) + var_12 = hash.digest() + var_13 = open(f'{var_5.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + var_13.write(f'hash_value={var_14.b64encode(var_12)}\n') + var_3 += f"Sensitive value '{var_5.utils.escape_for_html(input.decode('utf-8'))}' hashed and stored." + var_13.close() + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00883.py b/Samples_Obfuscated/BenchmarkTest00883.py new file mode 100644 index 0000000..42dce74 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00883.py @@ -0,0 +1,28 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xss-00/BenchmarkTest00883', methods=['GET']) + def BenchmarkTest00883_get(): + return var_1() + + @var_2.route('/benchmark/xss-00/BenchmarkTest00883', methods=['POST']) + def BenchmarkTest00883_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_query_parameter('BenchmarkTest00883') + if not var_7: + var_7 = '' + var_8 = 'alsosafe' + if var_7: + var_9 = [] + var_9.append('safe') + var_9.append(var_7) + var_9.append('moresafe') + var_9.pop(0) + var_8 = var_9[1] + var_3 += 'The value of the bar parameter is now in a custom header.' + var_3 = var_10((var_3, {'yourBenchmarkTest00883': var_8})) + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00891.py b/Samples_Obfuscated/BenchmarkTest00891.py new file mode 100644 index 0000000..13704eb --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00891.py @@ -0,0 +1,29 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/codeinj-00/BenchmarkTest00891', methods=['GET']) + def BenchmarkTest00891_get(): + return var_1() + + @var_2.route('/benchmark/codeinj-00/BenchmarkTest00891', methods=['POST']) + def BenchmarkTest00891_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_query_parameter('BenchmarkTest00891') + if not var_7: + var_7 = '' + import configparser + var_8 = 'safe!' + var_9 = var_10.ConfigParser() + var_9.add_section('section8968') + var_9.set('section8968', 'keyA-8968', 'a-Value') + var_9.set('section8968', 'keyB-8968', var_7) + var_8 = var_9.get('section8968', 'keyB-8968') + try: + var_3 += eval(var_8) + except: + var_3 += f"Error evaluating expression '{var_11(var_8)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00898.py b/Samples_Obfuscated/BenchmarkTest00898.py new file mode 100644 index 0000000..fb1c6bb --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00898.py @@ -0,0 +1,31 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/deserialization-00/BenchmarkTest00898', methods=['GET']) + def BenchmarkTest00898_get(): + return var_1() + + @var_2.route('/benchmark/deserialization-00/BenchmarkTest00898', methods=['POST']) + def BenchmarkTest00898_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_query_parameter('BenchmarkTest00898') + if not var_7: + var_7 = '' + var_8 = 'This should never happen' + if 'should' in var_8: + var_8 = var_7 + import pickle + import base64 + import helpers.utils + var_5.utils.sharedstr = 'no pickles to be seen here' + try: + var_9 = var_10.loads(var_11.urlsafe_b64decode(var_8)) + except: + var_3 += 'Unpickling failed!' + return var_3 + var_3 += f'shared string is {var_5.utils.sharedstr}' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00920.py b/Samples_Obfuscated/BenchmarkTest00920.py new file mode 100644 index 0000000..2c4aab2 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00920.py @@ -0,0 +1,38 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/pathtraver-01/BenchmarkTest00920', methods=['GET']) + def BenchmarkTest00920_get(): + return var_1() + + @var_2.route('/benchmark/pathtraver-01/BenchmarkTest00920', methods=['POST']) + def BenchmarkTest00920_post(): + var_3 = '' + import urllib.parse + var_4 = var_5.query_string.decode('utf-8') + var_6 = var_4.find('BenchmarkTest00920' + '=') + if var_6 == -1: + return f"request.query_string did not contain expected parameter '{'BenchmarkTest00920'}'." + var_7 = var_4[var_6 + len('BenchmarkTest00920') + 1:] + var_8 = var_7.find('&') + if var_8 != -1: + var_7 = var_7[:var_8] + var_7 = var_9.parse.unquote_plus(var_7) + import configparser + var_10 = 'safe!' + var_11 = var_12.ConfigParser() + var_11.add_section('section73877') + var_11.set('section73877', 'keyA-73877', 'a-Value') + var_11.set('section73877', 'keyB-73877', var_7) + var_10 = var_11.get('section73877', 'keyB-73877') + import pathlib + import helpers.utils + try: + var_13 = var_14.Path(var_15.utils.TESTFILES_DIR) + var_16 = var_13 / var_10 + var_3 += f"The beginning of file: '{var_17(str(var_16))}' is:\n\n{var_17(var_16.read_text()[:1000])}" + except OSError: + var_3 += f"Problem reading from file '{{escape_for_html(fileName)}}': {var_17(var_18.strerror)}" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00925.py b/Samples_Obfuscated/BenchmarkTest00925.py new file mode 100644 index 0000000..fe4bf21 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00925.py @@ -0,0 +1,32 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xss-00/BenchmarkTest00925', methods=['GET']) + def BenchmarkTest00925_get(): + return var_1() + + @var_2.route('/benchmark/xss-00/BenchmarkTest00925', methods=['POST']) + def BenchmarkTest00925_post(): + var_3 = '' + import urllib.parse + var_4 = var_5.query_string.decode('utf-8') + var_6 = var_4.find('BenchmarkTest00925' + '=') + if var_6 == -1: + return f"request.query_string did not contain expected parameter '{'BenchmarkTest00925'}'." + var_7 = var_4[var_6 + len('BenchmarkTest00925') + 1:] + var_8 = var_7.find('&') + if var_8 != -1: + var_7 = var_7[:var_8] + var_7 = var_9.parse.unquote_plus(var_7) + import configparser + var_10 = 'safe!' + var_11 = var_12.ConfigParser() + var_11.add_section('section82988') + var_11.set('section82988', 'keyA-82988', 'a-Value') + var_11.set('section82988', 'keyB-82988', var_7) + var_10 = var_11.get('section82988', 'keyB-82988') + var_13 = 'static text' + var_3 += "bar is '%s' and otherarg is '%s'" % (var_10, var_13) + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00929.py b/Samples_Obfuscated/BenchmarkTest00929.py new file mode 100644 index 0000000..31bab62 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00929.py @@ -0,0 +1,50 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xpathi-01/BenchmarkTest00929', methods=['GET']) + def BenchmarkTest00929_get(): + return var_1() + + @var_2.route('/benchmark/xpathi-01/BenchmarkTest00929', methods=['POST']) + def BenchmarkTest00929_post(): + var_3 = '' + import urllib.parse + var_4 = var_5.query_string.decode('utf-8') + var_6 = var_4.find('BenchmarkTest00929' + '=') + if var_6 == -1: + return f"request.query_string did not contain expected parameter '{'BenchmarkTest00929'}'." + var_7 = var_4[var_6 + len('BenchmarkTest00929') + 1:] + var_8 = var_7.find('&') + if var_8 != -1: + var_7 = var_7[:var_8] + var_7 = var_9.parse.unquote_plus(var_7) + var_10 = 'ABC' + var_11 = var_10[1] + match var_11: + case 'A': + var_12 = var_7 + case 'B': + var_12 = 'bob' + case 'C' | 'D': + var_12 = var_7 + case _: + var_12 = "bob's your uncle" + import elementpath + import xml.etree.ElementTree as ET + import helpers.utils + if "'" in var_12: + var_3 += 'Employee ID must not contain apostrophes' + return var_3 + try: + var_13 = var_14.parse(f'{var_15.utils.RES_DIR}/employees.xml') + var_16 = f"/Employees/Employee[@emplid='{var_12}']" + var_17 = var_18.select(var_13, var_16) + var_19 = [] + for var_20 in var_17: + var_19.append(' '.join([var_21.text for var_21 in var_20])) + var_3 += f"Your XPATH query results are:
[ {', '.join(var_19)} ]" + except: + var_3 += f"Error parsing XPath Query: '{var_22(var_16)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00930.py b/Samples_Obfuscated/BenchmarkTest00930.py new file mode 100644 index 0000000..5e109e2 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00930.py @@ -0,0 +1,43 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xxe-00/BenchmarkTest00930', methods=['GET']) + def BenchmarkTest00930_get(): + return var_1() + + @var_2.route('/benchmark/xxe-00/BenchmarkTest00930', methods=['POST']) + def BenchmarkTest00930_post(): + var_3 = '' + import urllib.parse + var_4 = var_5.query_string.decode('utf-8') + var_6 = var_4.find('BenchmarkTest00930' + '=') + if var_6 == -1: + return f"request.query_string did not contain expected parameter '{'BenchmarkTest00930'}'." + var_7 = var_4[var_6 + len('BenchmarkTest00930') + 1:] + var_8 = var_7.find('&') + if var_8 != -1: + var_7 = var_7[:var_8] + var_7 = var_9.parse.unquote_plus(var_7) + import base64 + var_10 = var_11.b64encode(var_7.encode('utf-8')) + var_12 = var_11.b64decode(var_10).decode('utf-8') + import xml.dom.minidom + import xml.sax.handler + try: + var_13 = var_14.sax.make_parser() + var_13.setFeature(var_14.sax.handler.feature_external_ges, True) + var_15 = var_14.dom.minidom.parseString(var_12, var_13) + var_16 = '' + var_17 = [var_15.documentElement] + while var_17: + var_18 = var_17.pop(0) + if var_18.nodeType == var_14.dom.Node.TEXT_NODE: + var_16 += var_18.data + else: + var_17[:0] = var_18.childNodes + var_3 += f'Your XML doc results are:
{var_19(var_16)}' + except: + var_3 += f'There was an error reading your XML doc:
{var_19(var_12)}' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00940.py b/Samples_Obfuscated/BenchmarkTest00940.py new file mode 100644 index 0000000..232970f --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00940.py @@ -0,0 +1,43 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xpathi-01/BenchmarkTest00940', methods=['GET']) + def BenchmarkTest00940_get(): + return var_1() + + @var_2.route('/benchmark/xpathi-01/BenchmarkTest00940', methods=['POST']) + def BenchmarkTest00940_post(): + var_3 = '' + import urllib.parse + var_4 = var_5.query_string.decode('utf-8') + var_6 = var_4.find('BenchmarkTest00940' + '=') + if var_6 == -1: + return f"request.query_string did not contain expected parameter '{'BenchmarkTest00940'}'." + var_7 = var_4[var_6 + len('BenchmarkTest00940') + 1:] + var_8 = var_7.find('&') + if var_8 != -1: + var_7 = var_7[:var_8] + var_7 = var_9.parse.unquote_plus(var_7) + var_10 = {} + var_10['keyA-33295'] = 'a-Value' + var_10['keyB-33295'] = var_7 + var_10['keyC'] = 'another-Value' + var_11 = 'safe!' + var_11 = var_10['keyB-33295'] + var_11 = var_10['keyA-33295'] + import lxml.etree + import helpers.utils + try: + var_12 = open(f'{var_13.utils.RES_DIR}/employees.xml', 'rb') + var_14 = var_15.etree.parse(var_12) + var_16 = f'/Employees/Employee[@emplid=$name]' + var_17 = var_14.xpath(var_16, name=var_11) + var_18 = [] + for var_19 in var_17: + var_18.append(' '.join([var_20.text for var_20 in var_19])) + var_3 += f"Your XPATH query results are:
[ {', '.join(var_18)} ]" + except: + var_3 += f"Error parsing XPath Query: '{var_21(var_16)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00941.py b/Samples_Obfuscated/BenchmarkTest00941.py new file mode 100644 index 0000000..2445cde --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00941.py @@ -0,0 +1,44 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xpathi-01/BenchmarkTest00941', methods=['GET']) + def BenchmarkTest00941_get(): + return var_1() + + @var_2.route('/benchmark/xpathi-01/BenchmarkTest00941', methods=['POST']) + def BenchmarkTest00941_post(): + var_3 = '' + import urllib.parse + var_4 = var_5.query_string.decode('utf-8') + var_6 = var_4.find('BenchmarkTest00941' + '=') + if var_6 == -1: + return f"request.query_string did not contain expected parameter '{'BenchmarkTest00941'}'." + var_7 = var_4[var_6 + len('BenchmarkTest00941') + 1:] + var_8 = var_7.find('&') + if var_8 != -1: + var_7 = var_7[:var_8] + var_7 = var_9.parse.unquote_plus(var_7) + var_10 = 'alsosafe' + if var_7: + var_11 = [] + var_11.append('safe') + var_11.append(var_7) + var_11.append('moresafe') + var_11.pop(0) + var_10 = var_11[1] + import lxml.etree + import helpers.utils + try: + var_12 = open(f'{var_13.utils.RES_DIR}/employees.xml', 'rb') + var_14 = var_15.etree.parse(var_12) + var_16 = f'/Employees/Employee[@emplid=$name]' + var_17 = var_14.xpath(var_16, name=var_10) + var_18 = [] + for var_19 in var_17: + var_18.append(' '.join([var_20.text for var_20 in var_19])) + var_3 += f"Your XPATH query results are:
[ {', '.join(var_18)} ]" + except: + var_3 += f"Error parsing XPath Query: '{var_21(var_16)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00947.py b/Samples_Obfuscated/BenchmarkTest00947.py new file mode 100644 index 0000000..d23b89a --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00947.py @@ -0,0 +1,37 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-03/BenchmarkTest00947', methods=['GET']) + def BenchmarkTest00947_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-03/BenchmarkTest00947', methods=['POST']) + def BenchmarkTest00947_post(): + var_3 = '' + import urllib.parse + var_4 = var_5.query_string.decode('utf-8') + var_6 = var_4.find('BenchmarkTest00947' + '=') + if var_6 == -1: + return f"request.query_string did not contain expected parameter '{'BenchmarkTest00947'}'." + var_7 = var_4[var_6 + len('BenchmarkTest00947') + 1:] + var_8 = var_7.find('&') + if var_8 != -1: + var_7 = var_7[:var_8] + var_7 = var_9.parse.unquote_plus(var_7) + import base64 + var_10 = var_11.b64encode(var_7.encode('utf-8')) + var_12 = var_11.b64decode(var_10).decode('utf-8') + import random + from helpers.utils import mysession + var_13 = 'BenchmarkTest00947'[13:] + var_14 = f'Nancy{var_13}' + var_15 = f'rememberMe{var_13}' + var_16 = str(var_17.normalvariate())[2:] + if var_15 in var_18 and var_5.cookies.get(var_15) == var_18[var_15]: + var_3 += f'Welcome back: {var_14}
' + else: + var_18[var_15] = var_16 + var_3 += f'{var_14} has been remembered with cookie: {var_15} whose value is: {var_18[var_15]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00957.py b/Samples_Obfuscated/BenchmarkTest00957.py new file mode 100644 index 0000000..d1cf86a --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00957.py @@ -0,0 +1,40 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-03/BenchmarkTest00957', methods=['GET']) + def BenchmarkTest00957_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-03/BenchmarkTest00957', methods=['POST']) + def BenchmarkTest00957_post(): + var_3 = '' + import urllib.parse + var_4 = var_5.query_string.decode('utf-8') + var_6 = var_4.find('BenchmarkTest00957' + '=') + if var_6 == -1: + return f"request.query_string did not contain expected parameter '{'BenchmarkTest00957'}'." + var_7 = var_4[var_6 + len('BenchmarkTest00957') + 1:] + var_8 = var_7.find('&') + if var_8 != -1: + var_7 = var_7[:var_8] + var_7 = var_9.parse.unquote_plus(var_7) + var_10 = 86 + if 7 * 42 - var_10 > 200: + var_11 = 'This_should_always_happen' + else: + var_11 = var_7 + import base64 + import secrets + from helpers.utils import mysession + var_10 = 'BenchmarkTest00957'[13:] + var_12 = f'SafeToby{var_10}' + var_13 = f'rememberMe{var_10}' + var_14 = var_15.b64encode(var_16.token_bytes(32)) + if var_13 in var_17 and var_5.cookies.get(var_13) == var_17[var_13]: + var_3 += f'Welcome back: {var_12}
' + else: + var_17[var_13] = var_14 + var_3 += f'{var_12} has been remembered with cookie:{var_13} whose value is: {var_17[var_13]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00959.py b/Samples_Obfuscated/BenchmarkTest00959.py new file mode 100644 index 0000000..04335ec --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00959.py @@ -0,0 +1,40 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-03/BenchmarkTest00959', methods=['GET']) + def BenchmarkTest00959_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-03/BenchmarkTest00959', methods=['POST']) + def BenchmarkTest00959_post(): + var_3 = '' + import urllib.parse + var_4 = var_5.query_string.decode('utf-8') + var_6 = var_4.find('BenchmarkTest00959' + '=') + if var_6 == -1: + return f"request.query_string did not contain expected parameter '{'BenchmarkTest00959'}'." + var_7 = var_4[var_6 + len('BenchmarkTest00959') + 1:] + var_8 = var_7.find('&') + if var_8 != -1: + var_7 = var_7[:var_8] + var_7 = var_9.parse.unquote_plus(var_7) + var_10 = {} + var_10['keyA-2927'] = 'a-Value' + var_10['keyB-2927'] = var_7 + var_10['keyC'] = 'another-Value' + var_11 = var_10['keyB-2927'] + import base64 + import secrets + from helpers.utils import mysession + var_12 = 'BenchmarkTest00959'[13:] + var_13 = f'SafeTruman{var_12}' + var_14 = f'rememberMe{var_12}' + var_15 = var_16.token_urlsafe(32) + if var_14 in var_17 and var_5.cookies.get(var_14) == var_17[var_14]: + var_3 += f'Welcome back: {var_13}
' + else: + var_17[var_14] = var_15 + var_3 += f'{var_13} has been remembered with cookie:{var_14} whose value is: {var_17[var_14]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00969.py b/Samples_Obfuscated/BenchmarkTest00969.py new file mode 100644 index 0000000..6cfe22c --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00969.py @@ -0,0 +1,35 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-03/BenchmarkTest00969', methods=['GET']) + def BenchmarkTest00969_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-03/BenchmarkTest00969', methods=['POST']) + def BenchmarkTest00969_post(): + var_3 = '' + import urllib.parse + var_4 = var_5.query_string.decode('utf-8') + var_6 = var_4.find('BenchmarkTest00969' + '=') + if var_6 == -1: + return f"request.query_string did not contain expected parameter '{'BenchmarkTest00969'}'." + var_7 = var_4[var_6 + len('BenchmarkTest00969') + 1:] + var_8 = var_7.find('&') + if var_8 != -1: + var_7 = var_7[:var_8] + var_7 = var_9.parse.unquote_plus(var_7) + var_10 = var_7 + import random + from helpers.utils import mysession + var_11 = 'BenchmarkTest00969'[13:] + var_12 = f'SafeIsaac{var_11}' + var_13 = f'rememberMe{var_11}' + var_14 = str(var_15.SystemRandom().randint(0, 2 ** 32)) + if var_13 in var_16 and var_5.cookies.get(var_13) == var_16[var_13]: + var_3 += f'Welcome back: {var_12}
' + else: + var_16[var_13] = var_14 + var_3 += f'{var_12} has been remembered with cookie: {var_13} whose value is: {var_16[var_13]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00974.py b/Samples_Obfuscated/BenchmarkTest00974.py new file mode 100644 index 0000000..92542aa --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00974.py @@ -0,0 +1,42 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/hash-01/BenchmarkTest00974', methods=['GET']) + def BenchmarkTest00974_get(): + return var_1() + + @var_2.route('/benchmark/hash-01/BenchmarkTest00974', methods=['POST']) + def BenchmarkTest00974_post(): + var_3 = '' + import urllib.parse + var_4 = var_5.query_string.decode('utf-8') + var_6 = var_4.find('BenchmarkTest00974' + '=') + if var_6 == -1: + return f"request.query_string did not contain expected parameter '{'BenchmarkTest00974'}'." + var_7 = var_4[var_6 + len('BenchmarkTest00974') + 1:] + var_8 = var_7.find('&') + if var_8 != -1: + var_7 = var_7[:var_8] + var_7 = var_9.parse.unquote_plus(var_7) + import helpers.utils + var_10 = var_11.utils.escape_for_html(var_7) + import hashlib, base64 + import io, helpers.utils + input = '' + if isinstance(var_10, str): + input = var_10.encode('utf-8') + elif isinstance(var_10, var_12.IOBase): + input = var_10.read(1000) + if len(input) == 0: + var_3 += 'Cannot generate hash: Input was empty.' + return var_3 + hash = var_13.new('md5') + hash.update(input) + var_14 = hash.digest() + var_15 = open(f'{var_11.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + var_15.write(f'hash_value={var_16.b64encode(var_14)}\n') + var_3 += f"Sensitive value '{var_11.utils.escape_for_html(input.decode('utf-8'))}' hashed and stored." + var_15.close() + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00995.py b/Samples_Obfuscated/BenchmarkTest00995.py new file mode 100644 index 0000000..f5327f5 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00995.py @@ -0,0 +1,31 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/deserialization-00/BenchmarkTest00995', methods=['GET']) + def BenchmarkTest00995_get(): + return var_1() + + @var_2.route('/benchmark/deserialization-00/BenchmarkTest00995', methods=['POST']) + def BenchmarkTest00995_post(): + var_3 = '' + import urllib.parse + var_4 = var_5.query_string.decode('utf-8') + var_6 = var_4.find('BenchmarkTest00995' + '=') + if var_6 == -1: + return f"request.query_string did not contain expected parameter '{'BenchmarkTest00995'}'." + var_7 = var_4[var_6 + len('BenchmarkTest00995') + 1:] + var_8 = var_7.find('&') + if var_8 != -1: + var_7 = var_7[:var_8] + var_7 = var_9.parse.unquote_plus(var_7) + var_10 = 106 + var_11 = 'This_should_always_happen' if 7 * 18 + var_10 > 200 else var_7 + import yaml + try: + var_12 = var_13.load(var_11, Loader=var_13.Loader) + var_3 += var_12['text'] + except: + var_3 += 'There was an error loading the configuration' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest00996.py b/Samples_Obfuscated/BenchmarkTest00996.py new file mode 100644 index 0000000..4bd3381 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest00996.py @@ -0,0 +1,36 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/deserialization-00/BenchmarkTest00996', methods=['GET']) + def BenchmarkTest00996_get(): + return var_1() + + @var_2.route('/benchmark/deserialization-00/BenchmarkTest00996', methods=['POST']) + def BenchmarkTest00996_post(): + var_3 = '' + import urllib.parse + var_4 = var_5.query_string.decode('utf-8') + var_6 = var_4.find('BenchmarkTest00996' + '=') + if var_6 == -1: + return f"request.query_string did not contain expected parameter '{'BenchmarkTest00996'}'." + var_7 = var_4[var_6 + len('BenchmarkTest00996') + 1:] + var_8 = var_7.find('&') + if var_8 != -1: + var_7 = var_7[:var_8] + var_7 = var_9.parse.unquote_plus(var_7) + var_10 = {} + var_10['keyA-4033'] = 'a-Value' + var_10['keyB-4033'] = var_7 + var_10['keyC'] = 'another-Value' + var_11 = 'safe!' + var_11 = var_10['keyB-4033'] + var_11 = var_10['keyA-4033'] + import yaml + try: + var_12 = var_13.safe_load(var_11) + var_3 += var_12['text'] + except: + var_3 += 'There was an error loading the configuration' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01001.py b/Samples_Obfuscated/BenchmarkTest01001.py new file mode 100644 index 0000000..d286d67 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01001.py @@ -0,0 +1,26 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xss-00/BenchmarkTest01001', methods=['GET']) + def BenchmarkTest01001_get(): + return var_1() + + @var_2.route('/benchmark/xss-00/BenchmarkTest01001', methods=['POST']) + def BenchmarkTest01001_post(): + var_3 = '' + var_4 = var_5.path.split('/') + var_6 = var_4[1] + if not var_6: + var_6 = '' + var_7 = '' + if var_6: + var_8 = [] + var_8.append('safe') + var_8.append(var_6) + var_8.append('moresafe') + var_8.pop(0) + var_7 = var_8[0] + var_3 += f'Parameter value: {var_7}' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01011.py b/Samples_Obfuscated/BenchmarkTest01011.py new file mode 100644 index 0000000..12363f8 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01011.py @@ -0,0 +1,35 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/pathtraver-01/BenchmarkTest01011', methods=['GET']) + def BenchmarkTest01011_get(): + return var_1() + + @var_2.route('/benchmark/pathtraver-01/BenchmarkTest01011', methods=['POST']) + def BenchmarkTest01011_post(): + var_3 = '' + var_4 = var_5.path.split('/') + var_6 = var_4[1] + if not var_6: + var_6 = '' + import configparser + var_7 = 'safe!' + var_8 = var_9.ConfigParser() + var_8.add_section('section92400') + var_8.set('section92400', 'keyA-92400', 'a_Value') + var_8.set('section92400', 'keyB-92400', var_6) + var_7 = var_8.get('section92400', 'keyA-92400') + import pathlib + import helpers.utils + try: + var_10 = var_11.Path(var_12.utils.TESTFILES_DIR) + var_13 = (var_10 / var_7).resolve() + if not str(var_13).startswith(str(var_10)): + var_3 += 'Invalid Path.' + return var_3 + var_3 += f"The beginning of file: '{var_14(str(var_13))}' is:\n\n{var_14(var_13.read_text()[:1000])}" + except OSError: + var_3 += f"Problem reading from file '{{escape_for_html(fileName)}}': {var_14(var_15.strerror)}" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01023.py b/Samples_Obfuscated/BenchmarkTest01023.py new file mode 100644 index 0000000..89ccd4d --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01023.py @@ -0,0 +1,40 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xpathi-01/BenchmarkTest01023', methods=['GET']) + def BenchmarkTest01023_get(): + return var_1() + + @var_2.route('/benchmark/xpathi-01/BenchmarkTest01023', methods=['POST']) + def BenchmarkTest01023_post(): + var_3 = '' + var_4 = var_5.path.split('/') + var_6 = var_4[1] + if not var_6: + var_6 = '' + var_7 = 'ABC' + var_8 = var_7[0] + match var_8: + case 'A': + var_9 = var_6 + case 'B': + var_9 = 'bob' + case 'C' | 'D': + var_9 = var_6 + case _: + var_9 = "bob's your uncle" + import elementpath + import xml.etree.ElementTree as ET + import helpers.utils + try: + var_10 = var_11.parse(f'{var_12.utils.RES_DIR}/employees.xml') + var_13 = var_14.select(var_10, f"""/Employees/Employee[@emplid='{var_9.replace("'", ''')}']""") + var_15 = [] + for var_16 in var_13: + var_15.append(' '.join([var_17.text for var_17 in var_16])) + var_3 += f"Your XPATH query results are:
[ {', '.join(var_15)} ]" + except: + var_3 += f"Error parsing XPath Query: '{var_18(var_19)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01026.py b/Samples_Obfuscated/BenchmarkTest01026.py new file mode 100644 index 0000000..2eb795e --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01026.py @@ -0,0 +1,33 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xpathi-01/BenchmarkTest01026', methods=['GET']) + def BenchmarkTest01026_get(): + return var_1() + + @var_2.route('/benchmark/xpathi-01/BenchmarkTest01026', methods=['POST']) + def BenchmarkTest01026_post(): + var_3 = '' + var_4 = var_5.path.split('/') + var_6 = var_4[1] + if not var_6: + var_6 = '' + import base64 + var_7 = var_8.b64encode(var_6.encode('utf-8')) + var_9 = var_8.b64decode(var_7).decode('utf-8') + import lxml.etree + import helpers.utils + try: + var_10 = open(f'{var_11.utils.RES_DIR}/employees.xml', 'rb') + var_12 = var_13.etree.parse(var_10) + var_14 = f"/Employees/Employee[@emplid='{var_9}']" + var_15 = var_12.xpath(var_14) + var_16 = [] + for var_17 in var_15: + var_16.append(' '.join([var_18.text for var_18 in var_17])) + var_3 += f"Your XPATH query results are:
[ {', '.join(var_16)} ]" + except: + var_3 += f"Error parsing XPath Query: '{var_19(var_14)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01035.py b/Samples_Obfuscated/BenchmarkTest01035.py new file mode 100644 index 0000000..18b2c83 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01035.py @@ -0,0 +1,34 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xpathi-02/BenchmarkTest01035', methods=['GET']) + def BenchmarkTest01035_get(): + return var_1() + + @var_2.route('/benchmark/xpathi-02/BenchmarkTest01035', methods=['POST']) + def BenchmarkTest01035_post(): + var_3 = '' + var_4 = var_5.path.split('/') + var_6 = var_4[1] + if not var_6: + var_6 = '' + var_7 = 'help' + var_7 += var_6 + var_7 += 'snapes on a plane' + var_8 = var_7[4:-17] + import lxml.etree + import helpers.utils + try: + var_9 = open(f'{var_10.utils.RES_DIR}/employees.xml', 'rb') + var_11 = var_12.etree.parse(var_9) + var_13 = f'/Employees/Employee[@emplid=$name]' + var_14 = var_11.xpath(var_13, name=var_8) + var_15 = [] + for var_16 in var_14: + var_15.append(' '.join([var_17.text for var_17 in var_16])) + var_3 += f"Your XPATH query results are:
[ {', '.join(var_15)} ]" + except: + var_3 += f"Error parsing XPath Query: '{var_18(var_13)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01040.py b/Samples_Obfuscated/BenchmarkTest01040.py new file mode 100644 index 0000000..da3f181 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01040.py @@ -0,0 +1,30 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-03/BenchmarkTest01040', methods=['GET']) + def BenchmarkTest01040_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-03/BenchmarkTest01040', methods=['POST']) + def BenchmarkTest01040_post(): + var_3 = '' + var_4 = var_5.path.split('/') + var_6 = var_4[1] + if not var_6: + var_6 = '' + import helpers.utils + var_7 = var_8.utils.escape_for_html(var_6) + import random + from helpers.utils import mysession + var_9 = 'BenchmarkTest01040'[13:] + var_10 = f'Randy{var_9}' + var_11 = f'rememberMe{var_9}' + var_12 = str(var_13.getrandbits(32)) + if var_11 in var_14 and var_5.cookies.get(var_11) == var_14[var_11]: + var_3 += f'Welcome back: {var_10}
' + else: + var_14[var_11] = var_12 + var_3 += f'{var_10} has been remembered with cookie: {var_11} whose value is: {var_14[var_11]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01044.py b/Samples_Obfuscated/BenchmarkTest01044.py new file mode 100644 index 0000000..5a45c0b --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01044.py @@ -0,0 +1,37 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-03/BenchmarkTest01044', methods=['GET']) + def BenchmarkTest01044_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-03/BenchmarkTest01044', methods=['POST']) + def BenchmarkTest01044_post(): + var_3 = '' + var_4 = var_5.path.split('/') + var_6 = var_4[1] + if not var_6: + var_6 = '' + var_7 = '' + if var_6: + var_8 = [] + var_8.append('safe') + var_8.append(var_6) + var_8.append('moresafe') + var_8.pop(0) + var_7 = var_8[0] + import random + import base64 + from helpers.utils import mysession + var_9 = 'BenchmarkTest01044'[13:] + var_10 = f'Barbara{var_9}' + var_11 = f'rememberMe{var_9}' + var_12 = str(var_13.b64encode(var_14.randbytes(32))) + if var_11 in var_15 and var_5.cookies.get(var_11) == var_15[var_11]: + var_3 += f'Welcome back: {var_10}
' + else: + var_15[var_11] = var_12 + var_3 += f'{var_10} has been remembered with cookie: {var_11} whose value is: {var_15[var_11]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01053.py b/Samples_Obfuscated/BenchmarkTest01053.py new file mode 100644 index 0000000..b524787 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01053.py @@ -0,0 +1,36 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-03/BenchmarkTest01053', methods=['GET']) + def BenchmarkTest01053_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-03/BenchmarkTest01053', methods=['POST']) + def BenchmarkTest01053_post(): + var_3 = '' + var_4 = var_5.path.split('/') + var_6 = var_4[1] + if not var_6: + var_6 = '' + import configparser + var_7 = 'safe!' + var_8 = var_9.ConfigParser() + var_8.add_section('section78986') + var_8.set('section78986', 'keyA-78986', 'a-Value') + var_8.set('section78986', 'keyB-78986', var_6) + var_7 = var_8.get('section78986', 'keyB-78986') + import base64 + import secrets + from helpers.utils import mysession + var_10 = 'BenchmarkTest01053'[13:] + var_11 = f'SafeToby{var_10}' + var_12 = f'rememberMe{var_10}' + var_13 = var_14.b64encode(var_15.token_bytes(32)) + if var_12 in var_16 and var_5.cookies.get(var_12) == var_16[var_12]: + var_3 += f'Welcome back: {var_11}
' + else: + var_16[var_12] = var_13 + var_3 += f'{var_11} has been remembered with cookie:{var_12} whose value is: {var_16[var_12]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01060.py b/Samples_Obfuscated/BenchmarkTest01060.py new file mode 100644 index 0000000..e5ae5eb --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01060.py @@ -0,0 +1,32 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-03/BenchmarkTest01060', methods=['GET']) + def BenchmarkTest01060_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-03/BenchmarkTest01060', methods=['POST']) + def BenchmarkTest01060_post(): + var_3 = '' + var_4 = var_5.path.split('/') + var_6 = var_4[1] + if not var_6: + var_6 = '' + import helpers.ThingFactory + var_7 = var_8.ThingFactory.createThing() + var_9 = var_7.doSomething(var_6) + import base64 + import secrets + from helpers.utils import mysession + var_10 = 'BenchmarkTest01060'[13:] + var_11 = f'SafeTruman{var_10}' + var_12 = f'rememberMe{var_10}' + var_13 = var_14.token_urlsafe(32) + if var_12 in var_15 and var_5.cookies.get(var_12) == var_15[var_12]: + var_3 += f'Welcome back: {var_11}
' + else: + var_15[var_12] = var_13 + var_3 += f'{var_11} has been remembered with cookie:{var_12} whose value is: {var_15[var_12]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01081.py b/Samples_Obfuscated/BenchmarkTest01081.py new file mode 100644 index 0000000..f1276bd --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01081.py @@ -0,0 +1,37 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/hash-01/BenchmarkTest01081', methods=['GET']) + def BenchmarkTest01081_get(): + return var_1() + + @var_2.route('/benchmark/hash-01/BenchmarkTest01081', methods=['POST']) + def BenchmarkTest01081_post(): + var_3 = '' + var_4 = var_5.path.split('/') + var_6 = var_4[1] + if not var_6: + var_6 = '' + import helpers.ThingFactory + var_7 = var_8.ThingFactory.createThing() + var_9 = var_7.doSomething(var_6) + import hashlib, base64 + import io, helpers.utils + input = '' + if isinstance(var_9, str): + input = var_9.encode('utf-8') + elif isinstance(var_9, var_10.IOBase): + input = var_9.read(1000) + if len(input) == 0: + var_3 += 'Cannot generate hash: Input was empty.' + return var_3 + hash = var_11.sha512() + hash.update(input) + var_12 = hash.digest() + var_13 = open(f'{var_8.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + var_13.write(f'hash_value={var_14.b64encode(var_12)}\n') + var_3 += f"Sensitive value '{var_8.utils.escape_for_html(input.decode('utf-8'))}' hashed and stored." + var_13.close() + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01084.py b/Samples_Obfuscated/BenchmarkTest01084.py new file mode 100644 index 0000000..b108893 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01084.py @@ -0,0 +1,21 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xss-01/BenchmarkTest01084', methods=['GET']) + def BenchmarkTest01084_get(): + return var_1() + + @var_2.route('/benchmark/xss-01/BenchmarkTest01084', methods=['POST']) + def BenchmarkTest01084_post(): + var_3 = '' + var_4 = var_5.path.split('/') + var_6 = var_4[1] + if not var_6: + var_6 = '' + var_7 = f'58606{var_6}abcd' + var_8 = var_7[len('58606'):len(var_7) - 5] + var_3 += 'The value of the bar parameter is now in a custom header.' + var_3 = var_9((var_3, {'yourBenchmarkTest01084': var_8})) + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01087.py b/Samples_Obfuscated/BenchmarkTest01087.py new file mode 100644 index 0000000..b789fc5 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01087.py @@ -0,0 +1,33 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/securecookie-00/BenchmarkTest01087', methods=['GET']) + def BenchmarkTest01087_get(): + return var_1() + + @var_2.route('/benchmark/securecookie-00/BenchmarkTest01087', methods=['POST']) + def BenchmarkTest01087_post(): + var_3 = '' + var_4 = var_5.path.split('/') + var_6 = var_4[1] + if not var_6: + var_6 = '' + var_7 = '' + if var_6: + var_7 = var_6.split(' ')[0] + from flask import make_response + import io + import helpers.utils + input = '' + if isinstance(var_7, str): + input = var_7.encode('utf-8') + elif isinstance(var_7, var_8.IOBase): + input = var_7.read(1000) + var_9 = 'SomeCookie' + var_10 = input.decode('utf-8') + var_3 += f"Created cookie: '{var_9}' with value '{var_11.utils.escape_for_html(var_10)}' and secure flag set to false." + var_3 = var_12(var_3) + var_3.set_cookie(var_9, var_10, path=var_5.path, secure=False, httponly=True) + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01091.py b/Samples_Obfuscated/BenchmarkTest01091.py new file mode 100644 index 0000000..1f0b0b7 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01091.py @@ -0,0 +1,31 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/redirect-00/BenchmarkTest01091', methods=['GET']) + def BenchmarkTest01091_get(): + return var_1() + + @var_2.route('/benchmark/redirect-00/BenchmarkTest01091', methods=['POST']) + def BenchmarkTest01091_post(): + var_3 = '' + var_4 = var_5.path.split('/') + var_6 = var_4[1] + if not var_6: + var_6 = '' + import helpers.ThingFactory + var_7 = var_8.ThingFactory.createThing() + var_9 = var_7.doSomething(var_6) + import flask + import urllib.parse + try: + var_10 = var_11.parse.urlparse(var_9) + if var_10.netloc not in ['google.com'] or var_10.scheme != 'https': + var_3 += 'Invalid URL.' + return var_3 + except: + var_3 += 'Error parsing URL.' + return var_3 + return var_12.redirect(var_9) + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01094.py b/Samples_Obfuscated/BenchmarkTest01094.py new file mode 100644 index 0000000..9b4029e --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01094.py @@ -0,0 +1,22 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/trustbound-00/BenchmarkTest01094', methods=['GET']) + def BenchmarkTest01094_get(): + return var_1() + + @var_2.route('/benchmark/trustbound-00/BenchmarkTest01094', methods=['POST']) + def BenchmarkTest01094_post(): + var_3 = '' + var_4 = var_5.path.split('/') + var_6 = var_4[1] + if not var_6: + var_6 = '' + var_7 = f'36072{var_6}abcd' + var_8 = var_7[len('36072'):len(var_7) - 5] + import flask + var_9.session[var_8] = '12345' + var_3 += f"Item: '{var_10(var_8)}' with value: 12345 saved in session." + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01099.py b/Samples_Obfuscated/BenchmarkTest01099.py new file mode 100644 index 0000000..10a14c3 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01099.py @@ -0,0 +1,30 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/deserialization-00/BenchmarkTest01099', methods=['GET']) + def BenchmarkTest01099_get(): + return var_1() + + @var_2.route('/benchmark/deserialization-00/BenchmarkTest01099', methods=['POST']) + def BenchmarkTest01099_post(): + var_3 = '' + var_4 = var_5.path.split('/') + var_6 = var_4[1] + if not var_6: + var_6 = '' + var_7 = '' + var_8 = '' + var_9 = var_7 + var_7 = '' + var_7 += var_6 + var_9 += 'SomeOKString' + var_10 = var_9 + import yaml + try: + var_11 = var_12.load(var_10, Loader=var_12.Loader) + var_3 += var_11['text'] + except: + var_3 += 'There was an error loading the configuration' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01100.py b/Samples_Obfuscated/BenchmarkTest01100.py new file mode 100644 index 0000000..8b5cc31 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01100.py @@ -0,0 +1,30 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/deserialization-00/BenchmarkTest01100', methods=['GET']) + def BenchmarkTest01100_get(): + return var_1() + + @var_2.route('/benchmark/deserialization-00/BenchmarkTest01100', methods=['POST']) + def BenchmarkTest01100_post(): + var_3 = '' + var_4 = var_5.path.split('/') + var_6 = var_4[1] + if not var_6: + var_6 = '' + import configparser + var_7 = 'safe!' + var_8 = var_9.ConfigParser() + var_8.add_section('section30057') + var_8.set('section30057', 'keyA-30057', 'a_Value') + var_8.set('section30057', 'keyB-30057', var_6) + var_7 = var_8.get('section30057', 'keyA-30057') + import yaml + try: + var_10 = var_11.safe_load(var_7) + var_3 += var_10['text'] + except: + var_3 += 'There was an error loading the configuration' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01104.py b/Samples_Obfuscated/BenchmarkTest01104.py new file mode 100644 index 0000000..660506b --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01104.py @@ -0,0 +1,20 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xss-01/BenchmarkTest01104', methods=['GET']) + def BenchmarkTest01104_get(): + return var_1() + + @var_2.route('/benchmark/xss-01/BenchmarkTest01104', methods=['POST']) + def BenchmarkTest01104_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_safe_value('BenchmarkTest01104') + import helpers.ThingFactory + var_8 = var_5.ThingFactory.createThing() + var_9 = var_8.doSomething(var_7) + var_3 += f'Parameter value: {var_9}' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01105.py b/Samples_Obfuscated/BenchmarkTest01105.py new file mode 100644 index 0000000..8ab42a2 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01105.py @@ -0,0 +1,38 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/pathtraver-01/BenchmarkTest01105', methods=['GET']) + def BenchmarkTest01105_get(): + return var_1() + + @var_2.route('/benchmark/pathtraver-01/BenchmarkTest01105', methods=['POST']) + def BenchmarkTest01105_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_safe_value('BenchmarkTest01105') + var_8 = {} + var_8['keyA-12023'] = 'a-Value' + var_8['keyB-12023'] = var_7 + var_8['keyC'] = 'another-Value' + var_9 = 'safe!' + var_9 = var_8['keyB-12023'] + var_9 = var_8['keyA-12023'] + import helpers.utils + var_10 = None + var_11 = None + try: + var_10 = f'{var_5.utils.TESTFILES_DIR}/{var_9}' + var_11 = open(var_10, 'rb') + var_3 += f"The beginning of file: '{var_12(var_10)}' is:\n\n{var_12(var_11.read(1000).decode('utf-8'))}" + except IOError as e: + var_3 += f"Problem reading from file '{{escape_for_html(fileName)}}': {var_12(var_13.strerror)}" + finally: + try: + if var_11 is not None: + var_11.close() + except IOError: + pass + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01117.py b/Samples_Obfuscated/BenchmarkTest01117.py new file mode 100644 index 0000000..2992eea --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01117.py @@ -0,0 +1,35 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xpathi-02/BenchmarkTest01117', methods=['GET']) + def BenchmarkTest01117_get(): + return var_1() + + @var_2.route('/benchmark/xpathi-02/BenchmarkTest01117', methods=['POST']) + def BenchmarkTest01117_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_safe_value('BenchmarkTest01117') + var_8 = {} + var_8['keyA-8971'] = 'a-Value' + var_8['keyB-8971'] = var_7 + var_8['keyC'] = 'another-Value' + var_9 = 'safe!' + var_9 = var_8['keyB-8971'] + var_9 = var_8['keyA-8971'] + import elementpath + import xml.etree.ElementTree as ET + import helpers.utils + try: + var_10 = var_11.parse(f'{var_5.utils.RES_DIR}/employees.xml') + var_12 = var_13.select(var_10, f"""/Employees/Employee[@emplid='{var_9.replace("'", ''')}']""") + var_14 = [] + for var_15 in var_12: + var_14.append(' '.join([var_16.text for var_16 in var_15])) + var_3 += f"Your XPATH query results are:
[ {', '.join(var_14)} ]" + except: + var_3 += f"Error parsing XPath Query: '{var_17(var_18)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01126.py b/Samples_Obfuscated/BenchmarkTest01126.py new file mode 100644 index 0000000..5f5c995 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01126.py @@ -0,0 +1,35 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-03/BenchmarkTest01126', methods=['GET']) + def BenchmarkTest01126_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-03/BenchmarkTest01126', methods=['POST']) + def BenchmarkTest01126_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_safe_value('BenchmarkTest01126') + var_8 = 'alsosafe' + if var_7: + var_9 = [] + var_9.append('safe') + var_9.append(var_7) + var_9.append('moresafe') + var_9.pop(0) + var_8 = var_9[1] + import random + from helpers.utils import mysession + var_10 = 'BenchmarkTest01126'[13:] + var_11 = f'Nancy{var_10}' + var_12 = f'rememberMe{var_10}' + var_13 = str(var_14.normalvariate())[2:] + if var_12 in var_15 and var_6.cookies.get(var_12) == var_15[var_12]: + var_3 += f'Welcome back: {var_11}
' + else: + var_15[var_12] = var_13 + var_3 += f'{var_11} has been remembered with cookie: {var_12} whose value is: {var_15[var_12]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01131.py b/Samples_Obfuscated/BenchmarkTest01131.py new file mode 100644 index 0000000..4bbe107 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01131.py @@ -0,0 +1,31 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-03/BenchmarkTest01131', methods=['GET']) + def BenchmarkTest01131_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-03/BenchmarkTest01131', methods=['POST']) + def BenchmarkTest01131_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_safe_value('BenchmarkTest01131') + var_8 = 'help' + var_8 += var_7 + var_8 += 'snapes on a plane' + var_9 = var_8[4:-17] + import random + from helpers.utils import mysession + var_10 = 'BenchmarkTest01131'[13:] + var_11 = f'Randall{var_10}' + var_12 = f'rememberMe{var_10}' + var_13 = str(var_14.random())[2:] + if var_12 in var_15 and var_6.cookies.get(var_12) == var_15[var_12]: + var_3 += f'Welcome back: {var_11}
' + else: + var_15[var_12] = var_13 + var_3 += f'{var_11} has been remembered with cookie: {var_12} whose value is: {var_15[var_12]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01134.py b/Samples_Obfuscated/BenchmarkTest01134.py new file mode 100644 index 0000000..0bf2080 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01134.py @@ -0,0 +1,31 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-03/BenchmarkTest01134', methods=['GET']) + def BenchmarkTest01134_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-03/BenchmarkTest01134', methods=['POST']) + def BenchmarkTest01134_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_safe_value('BenchmarkTest01134') + var_8 = 'help' + var_8 += var_7 + var_8 += 'snapes on a plane' + var_9 = var_8[4:-17] + import secrets + from helpers.utils import mysession + var_10 = 'BenchmarkTest01134'[13:] + var_11 = f'SafeRobbie{var_10}' + var_12 = f'rememberMe{var_10}' + var_13 = str(var_14.randbelow(2 ** 32)) + if var_12 in var_15 and var_6.cookies.get(var_12) == var_15[var_12]: + var_3 += f'Welcome back: {var_11}
' + else: + var_15[var_12] = var_13 + var_3 += f'{var_11} has been remembered with cookie:{var_12} whose value is: {var_15[var_12]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01135.py b/Samples_Obfuscated/BenchmarkTest01135.py new file mode 100644 index 0000000..6b593a6 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01135.py @@ -0,0 +1,29 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-03/BenchmarkTest01135', methods=['GET']) + def BenchmarkTest01135_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-03/BenchmarkTest01135', methods=['POST']) + def BenchmarkTest01135_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_safe_value('BenchmarkTest01135') + var_8 = f'40994{var_7}abcd' + var_9 = var_8[len('40994'):len(var_8) - 5] + import secrets + from helpers.utils import mysession + var_10 = 'BenchmarkTest01135'[13:] + var_11 = f'SafeRobbie{var_10}' + var_12 = f'rememberMe{var_10}' + var_13 = str(var_14.randbelow(2 ** 32)) + if var_12 in var_15 and var_6.cookies.get(var_12) == var_15[var_12]: + var_3 += f'Welcome back: {var_11}
' + else: + var_15[var_12] = var_13 + var_3 += f'{var_11} has been remembered with cookie:{var_12} whose value is: {var_15[var_12]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01141.py b/Samples_Obfuscated/BenchmarkTest01141.py new file mode 100644 index 0000000..f7f26a0 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01141.py @@ -0,0 +1,36 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-03/BenchmarkTest01141', methods=['GET']) + def BenchmarkTest01141_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-03/BenchmarkTest01141', methods=['POST']) + def BenchmarkTest01141_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_safe_value('BenchmarkTest01141') + var_8 = '' + if var_7: + var_9 = [] + var_9.append('safe') + var_9.append(var_7) + var_9.append('moresafe') + var_9.pop(0) + var_8 = var_9[0] + import random + import base64 + from helpers.utils import mysession + var_10 = 'BenchmarkTest01141'[13:] + var_11 = f'SafeBarbara{var_10}' + var_12 = f'rememberMe{var_10}' + var_13 = str(var_14.b64encode(var_15.SystemRandom().randbytes(32))) + if var_12 in var_16 and var_6.cookies.get(var_12) == var_16[var_12]: + var_3 += f'Welcome back: {var_11}
' + else: + var_16[var_12] = var_13 + var_3 += f'{var_11} has been remembered with cookie: {var_12} whose value is: {var_16[var_12]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01150.py b/Samples_Obfuscated/BenchmarkTest01150.py new file mode 100644 index 0000000..b948522 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01150.py @@ -0,0 +1,40 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/hash-01/BenchmarkTest01150', methods=['GET']) + def BenchmarkTest01150_get(): + return var_1() + + @var_2.route('/benchmark/hash-01/BenchmarkTest01150', methods=['POST']) + def BenchmarkTest01150_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_safe_value('BenchmarkTest01150') + var_8 = {} + var_8['keyA-23948'] = 'a-Value' + var_8['keyB-23948'] = var_7 + var_8['keyC'] = 'another-Value' + var_9 = 'safe!' + var_9 = var_8['keyB-23948'] + var_9 = var_8['keyA-23948'] + import hashlib, base64 + import io, helpers.utils + input = '' + if isinstance(var_9, str): + input = var_9.encode('utf-8') + elif isinstance(var_9, var_10.IOBase): + input = var_9.read(1000) + if len(input) == 0: + var_3 += 'Cannot generate hash: Input was empty.' + return var_3 + hash = var_11.sha384() + hash.update(input) + var_12 = hash.digest() + var_13 = open(f'{var_5.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + var_13.write(f'hash_value={var_14.b64encode(var_12)}\n') + var_3 += f"Sensitive value '{var_5.utils.escape_for_html(input.decode('utf-8'))}' hashed and stored." + var_13.close() + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01162.py b/Samples_Obfuscated/BenchmarkTest01162.py new file mode 100644 index 0000000..a1b49f9 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01162.py @@ -0,0 +1,20 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/trustbound-00/BenchmarkTest01162', methods=['GET']) + def BenchmarkTest01162_get(): + return var_1() + + @var_2.route('/benchmark/trustbound-00/BenchmarkTest01162', methods=['POST']) + def BenchmarkTest01162_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_safe_value('BenchmarkTest01162') + var_8 = var_7 + import flask + var_9.session[var_8] = '12345' + var_3 += f"Item: '{var_10(var_8)}' with value: 12345 saved in session." + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01170.py b/Samples_Obfuscated/BenchmarkTest01170.py new file mode 100644 index 0000000..5c201ce --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01170.py @@ -0,0 +1,43 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/ldapi-00/BenchmarkTest01170', methods=['GET']) + def BenchmarkTest01170_get(): + return var_1() + + @var_2.route('/benchmark/ldapi-00/BenchmarkTest01170', methods=['POST']) + def BenchmarkTest01170_post(): + var_3 = '' + import helpers.separate_request + var_4 = var_5.separate_request.request_wrapper(var_6) + var_7 = var_4.get_safe_value('BenchmarkTest01170') + var_8 = 'ABC' + var_9 = var_8[1] + match var_9: + case 'A': + var_10 = var_7 + case 'B': + var_10 = 'bob' + case 'C' | 'D': + var_10 = var_7 + case _: + var_10 = "bob's your uncle" + import helpers.ldap + import ldap3 + var_11 = 'ou=users,ou=system' + filter = f'(&(objectclass=person)(|(uid={var_10})(street=The streetz 4 Ms bar)))' + try: + var_12 = var_5.ldap.get_connection() + var_12.search(var_11, filter, attributes=var_13.ALL_ATTRIBUTES) + var_14 = False + for var_15 in var_12.entries: + var_3 += f"LDAP query results:
Record found with name {var_15['uid']}
Address: {var_15['street']}
" + var_14 = True + var_12.unbind() + if not var_14: + var_3 += f'LDAP query results: nothing found for query: {var_5.utils.escape_for_html(filter)}' + except: + var_3 += 'Error processing LDAP query.' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01181.py b/Samples_Obfuscated/BenchmarkTest01181.py new file mode 100644 index 0000000..c3362d9 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01181.py @@ -0,0 +1,23 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/pathtraver-01/BenchmarkTest01181', methods=['GET']) + def BenchmarkTest01181_get(): + return var_1() + + @var_2.route('/benchmark/pathtraver-01/BenchmarkTest01181', methods=['POST']) + def BenchmarkTest01181_post(): + var_3 = '' + var_4 = var_5.form.get('BenchmarkTest01181') + if not var_4: + var_4 = '' + import os + import helpers.utils + var_6 = f'{var_7.utils.TESTFILES_DIR}/{var_4}' + if var_8.path.exists(var_6): + var_3 += f"File '{var_9(var_6)}' exists." + else: + var_3 += f"File '{var_9(var_6)}' does not exist." + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01183.py b/Samples_Obfuscated/BenchmarkTest01183.py new file mode 100644 index 0000000..b60f4b5 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01183.py @@ -0,0 +1,26 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/pathtraver-02/BenchmarkTest01183', methods=['GET']) + def BenchmarkTest01183_get(): + return var_1() + + @var_2.route('/benchmark/pathtraver-02/BenchmarkTest01183', methods=['POST']) + def BenchmarkTest01183_post(): + var_3 = '' + var_4 = var_5.form.getlist('BenchmarkTest01183') + var_6 = '' + if var_4: + var_6 = var_4[0] + import helpers.utils + var_7 = None + var_8 = None + try: + var_7 = f'{var_9.utils.TESTFILES_DIR}/{var_6}' + with open(var_7, 'rb') as var_8: + var_3 += f"The beginning of file: '{var_10(var_7)}' is:\n\n{var_10(var_8.read(1000).decode('utf-8'))}" + except IOError as e: + var_3 += f"Problem reading from file '{{escape_for_html(fileName)}}': {var_10(var_11.strerror)}" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01196.py b/Samples_Obfuscated/BenchmarkTest01196.py new file mode 100644 index 0000000..23ddac3 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01196.py @@ -0,0 +1,23 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/pathtraver-02/BenchmarkTest01196', methods=['GET']) + def BenchmarkTest01196_get(): + return var_1() + + @var_2.route('/benchmark/pathtraver-02/BenchmarkTest01196', methods=['POST']) + def BenchmarkTest01196_post(): + var_3 = '' + var_4 = var_5.headers.get('BenchmarkTest01196') + if not var_4: + var_4 = '' + import helpers.utils + try: + var_6 = f'{var_7.utils.TESTFILES_DIR}/{var_4}' + with open(var_6, 'wb') as var_8: + var_3 += f'Now ready to write to file: {var_9(var_6)}' + except IOError as e: + var_3 += f"Problem reading from file '{var_9(var_6)}': {var_9(var_10.strerror)}" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01198.py b/Samples_Obfuscated/BenchmarkTest01198.py new file mode 100644 index 0000000..10bd8f4 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01198.py @@ -0,0 +1,33 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xpathi-02/BenchmarkTest01198', methods=['GET']) + def BenchmarkTest01198_get(): + return var_1() + + @var_2.route('/benchmark/xpathi-02/BenchmarkTest01198', methods=['POST']) + def BenchmarkTest01198_post(): + var_3 = '' + var_4 = '' + var_5 = var_6.headers.getlist('BenchmarkTest01198') + if var_5: + var_4 = var_5[0] + import lxml.etree + import helpers.utils + try: + if "'" in var_4: + var_3 += 'Employee ID must not contain apostrophes' + return var_3 + var_7 = open(f'{var_8.utils.RES_DIR}/employees.xml', 'rb') + var_9 = var_10.etree.parse(var_7) + var_11 = f"/Employees/Employee[@emplid='{var_4}']" + var_12 = var_9.xpath(var_11) + var_13 = [] + for var_14 in var_12: + var_13.append(' '.join([var_15.text for var_15 in var_14])) + var_3 += f"Your XPATH query results are:
[ {', '.join(var_13)} ]" + except: + var_3 += f"Error parsing XPath Query: '{var_16(var_11)}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01205.py b/Samples_Obfuscated/BenchmarkTest01205.py new file mode 100644 index 0000000..1a044e6 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01205.py @@ -0,0 +1,27 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/weakrand-04/BenchmarkTest01205', methods=['GET']) + def BenchmarkTest01205_get(): + return var_1() + + @var_2.route('/benchmark/weakrand-04/BenchmarkTest01205', methods=['POST']) + def BenchmarkTest01205_post(): + var_3 = '' + var_4 = var_5.args.get('BenchmarkTest01205') + if not var_4: + var_4 = '' + import secrets + from helpers.utils import mysession + var_6 = 'BenchmarkTest01205'[13:] + var_7 = f'SafeRobbie{var_6}' + var_8 = f'rememberMe{var_6}' + var_9 = str(var_10.randbelow(2 ** 32)) + if var_8 in var_11 and var_5.cookies.get(var_8) == var_11[var_8]: + var_3 += f'Welcome back: {var_7}
' + else: + var_11[var_8] = var_9 + var_3 += f'{var_7} has been remembered with cookie:{var_8} whose value is: {var_11[var_8]}
' + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01206.py b/Samples_Obfuscated/BenchmarkTest01206.py new file mode 100644 index 0000000..0b3d4d8 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01206.py @@ -0,0 +1,33 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/hash-01/BenchmarkTest01206', methods=['GET']) + def BenchmarkTest01206_get(): + return var_1() + + @var_2.route('/benchmark/hash-01/BenchmarkTest01206', methods=['POST']) + def BenchmarkTest01206_post(): + var_3 = '' + var_4 = var_5.args.get('BenchmarkTest01206') + if not var_4: + var_4 = '' + import hashlib, base64 + import io, helpers.utils + input = '' + if isinstance(var_4, str): + input = var_4.encode('utf-8') + elif isinstance(var_4, var_6.IOBase): + input = var_4.read(1000) + if len(input) == 0: + var_3 += 'Cannot generate hash: Input was empty.' + return var_3 + hash = var_7.sha384() + hash.update(input) + var_8 = hash.digest() + var_9 = open(f'{var_10.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + var_9.write(f'hash_value={var_11.b64encode(var_8)}\n') + var_3 += f"Sensitive value '{var_10.utils.escape_for_html(input.decode('utf-8'))}' hashed and stored." + var_9.close() + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01207.py b/Samples_Obfuscated/BenchmarkTest01207.py new file mode 100644 index 0000000..f77b8e6 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01207.py @@ -0,0 +1,29 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/securecookie-00/BenchmarkTest01207', methods=['GET']) + def BenchmarkTest01207_get(): + return var_1() + + @var_2.route('/benchmark/securecookie-00/BenchmarkTest01207', methods=['POST']) + def BenchmarkTest01207_post(): + var_3 = '' + var_4 = var_5.args.get('BenchmarkTest01207') + if not var_4: + var_4 = '' + from flask import make_response + import io + import helpers.utils + input = '' + if isinstance(var_4, str): + input = var_4.encode('utf-8') + elif isinstance(var_4, var_6.IOBase): + input = var_4.read(1000) + var_7 = 'SomeCookie' + var_8 = input.decode('utf-8') + var_3 += f"Created cookie: '{var_7}' with value '{var_9.utils.escape_for_html(var_8)}' and secure flag set to false." + var_3 = var_10(var_3) + var_3.set_cookie(var_7, var_8, path=var_5.path, secure=True, httponly=True) + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01210.py b/Samples_Obfuscated/BenchmarkTest01210.py new file mode 100644 index 0000000..c2fbae2 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01210.py @@ -0,0 +1,19 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/xss-01/BenchmarkTest01210', methods=['GET']) + def BenchmarkTest01210_get(): + return var_1() + + @var_2.route('/benchmark/xss-01/BenchmarkTest01210', methods=['POST']) + def BenchmarkTest01210_post(): + var_3 = '' + var_4 = var_5.args.getlist('BenchmarkTest01210') + var_6 = '' + if var_4: + var_6 = var_4[0] + var_7 = 'static text' + var_3 += f"param is '{var_6}' and otherarg is '{var_7}'" + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01221.py b/Samples_Obfuscated/BenchmarkTest01221.py new file mode 100644 index 0000000..0ac3958 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01221.py @@ -0,0 +1,35 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/pathtraver-02/BenchmarkTest01221', methods=['GET']) + def BenchmarkTest01221_get(): + return var_1() + + @var_2.route('/benchmark/pathtraver-02/BenchmarkTest01221', methods=['POST']) + def BenchmarkTest01221_post(): + var_3 = '' + var_4 = var_5.path.split('/') + var_6 = var_4[1] + if not var_6: + var_6 = '' + import helpers.utils + var_7 = None + var_8 = None + if '../' in var_6: + var_3 += "File name must not include '../'" + return var_3 + try: + var_7 = f'{var_9.utils.TESTFILES_DIR}/{var_6}' + var_8 = open(var_7, 'rb') + var_3 += f"The beginning of file: '{var_10(var_7)}' is:\n\n{var_10(var_8.read(1000).decode('utf-8'))}" + except IOError as e: + var_3 += f"Problem reading from file '{{escape_for_html(fileName)}}': {var_10(var_11.strerror)}" + finally: + try: + if var_8 is not None: + var_8.close() + except IOError: + pass + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01222.py b/Samples_Obfuscated/BenchmarkTest01222.py new file mode 100644 index 0000000..656f78a --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01222.py @@ -0,0 +1,30 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/pathtraver-02/BenchmarkTest01222', methods=['GET']) + def BenchmarkTest01222_get(): + return var_1() + + @var_2.route('/benchmark/pathtraver-02/BenchmarkTest01222', methods=['POST']) + def BenchmarkTest01222_post(): + var_3 = '' + var_4 = var_5.path.split('/') + var_6 = var_4[1] + if not var_6: + var_6 = '' + import helpers.utils + try: + var_7 = f'{var_8.utils.TESTFILES_DIR}/{var_6}' + var_9 = open(var_7, 'wb') + var_3 += f'Now ready to write to file: {var_10(var_7)}' + except IOError as e: + var_3 += f"Problem reading from file '{var_10(var_7)}': {var_10(var_11.strerror)}" + finally: + try: + if var_9 is not None: + var_9.close() + except IOError: + pass + return var_3 \ No newline at end of file diff --git a/Samples_Obfuscated/BenchmarkTest01227.py b/Samples_Obfuscated/BenchmarkTest01227.py new file mode 100644 index 0000000..f53fef7 --- /dev/null +++ b/Samples_Obfuscated/BenchmarkTest01227.py @@ -0,0 +1,34 @@ +from flask import redirect, url_for, request, make_response, render_template +from helpers.utils import escape_for_html + +def init(app): + + @var_2.route('/benchmark/hash-01/BenchmarkTest01227', methods=['GET']) + def BenchmarkTest01227_get(): + return var_1() + + @var_2.route('/benchmark/hash-01/BenchmarkTest01227', methods=['POST']) + def BenchmarkTest01227_post(): + var_3 = '' + var_4 = var_5.path.split('/') + var_6 = var_4[1] + if not var_6: + var_6 = '' + import hashlib, base64 + import io, helpers.utils + input = '' + if isinstance(var_6, str): + input = var_6.encode('utf-8') + elif isinstance(var_6, var_7.IOBase): + input = var_6.read(1000) + if len(input) == 0: + var_3 += 'Cannot generate hash: Input was empty.' + return var_3 + hash = var_8.new('md5') + hash.update(input) + var_9 = hash.digest() + var_10 = open(f'{var_11.utils.TESTFILES_DIR}/passwordFile.txt', 'a') + var_10.write(f'hash_value={var_12.b64encode(var_9)}\n') + var_3 += f"Sensitive value '{var_11.utils.escape_for_html(input.decode('utf-8'))}' hashed and stored." + var_10.close() + return var_3 \ No newline at end of file diff --git a/obfuscator.py b/obfuscator.py new file mode 100644 index 0000000..d1b8a7d --- /dev/null +++ b/obfuscator.py @@ -0,0 +1,50 @@ +import ast +import os + +class CleanAndObfuscate(ast.NodeTransformer): + def __init__(self): + self.mapping = {} + self.counter = 0 + + def visit_Expr(self, node): + # Remove standalone string statements (docstrings) + if isinstance(node.value, ast.Constant) and isinstance(node.value.value, str): + return None + return self.generic_visit(node) + + def visit_Name(self, node): + # Preserve built-in Python keywords/functions + if node.id in __builtins__.__dict__: + return node + if node.id not in self.mapping: + self.counter += 1 + self.mapping[node.id] = f"var_{self.counter}" + node.id = self.mapping[node.id] + return node + +def process_code(code_string): + parsed = ast.parse(code_string) + transformer = CleanAndObfuscate() + transformed = transformer.visit(parsed) + ast.fix_missing_locations(transformed) + return ast.unparse(transformed) + +# Directory execution +raw_dir = "/home/joren/Documents/JU/ResearchMethods/Project/Samples" +obfuscated_dir = "/home/joren/Documents/JU/ResearchMethods/Project/Samples_Obfuscated" +os.makedirs(obfuscated_dir, exist_ok=True) + +for fname in os.listdir(raw_dir): + if fname.endswith(".py"): + src_path = os.path.join(raw_dir, fname) + dst_path = os.path.join(obfuscated_dir, fname) + + with open(src_path, "r", encoding="utf-8") as f: + code = f.read() + + clean_code = process_code(code) + + with open(dst_path, "w", encoding="utf-8") as f: + f.write(clean_code) + +print("Obfuscation complete. All comments and docstrings stripped.")