PageRenderTime 40ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/core/main/client/os.js

https://github.com/dsqmoore/beef
JavaScript | 167 lines | 109 code | 40 blank | 18 comment | 37 complexity | 8294869618894ddbe2538fb4d6ed962e MD5 | raw file
Possible License(s): GPL-2.0
  1. //
  2. // Copyright (c) 2006-2013 Wade Alcorn - wade@bindshell.net
  3. // Browser Exploitation Framework (BeEF) - http://beefproject.com
  4. // See the file 'doc/COPYING' for copying permission
  5. //
  6. beef.os = {
  7. ua: navigator.userAgent,
  8. isWin311: function() {
  9. return (this.ua.indexOf("Win16") != -1) ? true : false;
  10. },
  11. isWinNT4: function() {
  12. return (this.ua.match('(Windows NT 4.0)')) ? true : false;
  13. },
  14. isWin95: function() {
  15. return (this.ua.match('(Windows 95)|(Win95)|(Windows_95)')) ? true : false;
  16. },
  17. isWin98: function() {
  18. return (this.ua.match('(Windows 98)|(Win98)')) ? true : false;
  19. },
  20. isWinME: function() {
  21. return (this.ua.indexOf('Windows ME') != -1) ? true : false;
  22. },
  23. isWin2000: function() {
  24. return (this.ua.match('(Windows NT 5.0)|(Windows 2000)')) ? true : false;
  25. },
  26. isWinXP: function() {
  27. return (this.ua.match('(Windows NT 5.1)|(Windows XP)')) ? true : false;
  28. },
  29. isWinServer2003: function() {
  30. return (this.ua.match('(Windows NT 5.2)')) ? true : false;
  31. },
  32. isWinVista: function() {
  33. return (this.ua.match('(Windows NT 6.0)')) ? true : false;
  34. },
  35. isWin7: function() {
  36. return (this.ua.match('(Windows NT 6.1)|(Windows NT 7.0)')) ? true : false;
  37. },
  38. isOpenBSD: function() {
  39. return (this.ua.indexOf('OpenBSD') != -1) ? true : false;
  40. },
  41. isSunOS: function() {
  42. return (this.ua.indexOf('SunOS') != -1) ? true : false;
  43. },
  44. isLinux: function() {
  45. return (this.ua.match('(Linux)|(X11)')) ? true : false;
  46. },
  47. isMacintosh: function() {
  48. return (this.ua.match('(Mac_PowerPC)|(Macintosh)|(MacIntel)')) ? true : false;
  49. },
  50. isWinPhone: function() {
  51. return (this.ua.match('(Windows Phone)')) ? true : false;
  52. },
  53. isIphone: function() {
  54. return (this.ua.indexOf('iPhone') != -1) ? true : false;
  55. },
  56. isIpad: function() {
  57. return (this.ua.indexOf('iPad') != -1) ? true : false;
  58. },
  59. isIpod: function() {
  60. return (this.ua.indexOf('iPod') != -1) ? true : false;
  61. },
  62. isNokia: function() {
  63. return (this.ua.match('(Maemo Browser)|(Symbian)|(Nokia)')) ? true : false;
  64. },
  65. isAndroid: function() {
  66. return (this.ua.match('Android')) ? true : false;
  67. },
  68. isBlackBerry: function() {
  69. return (this.ua.match('BlackBerry')) ? true : false;
  70. },
  71. isWebOS: function() {
  72. return (this.ua.match('webOS')) ? true : false;
  73. },
  74. isQNX: function() {
  75. return (this.ua.match('QNX')) ? true : false;
  76. },
  77. isBeOS: function() {
  78. return (this.ua.match('BeOS')) ? true : false;
  79. },
  80. getName: function() {
  81. //windows
  82. if(this.isWin311()) return 'Windows 3.11';
  83. if(this.isWinNT4()) return 'Windows NT 4';
  84. if(this.isWin95()) return 'Windows 95';
  85. if(this.isWin98()) return 'Windows 98';
  86. if(this.isWinME()) return 'Windows Millenium';
  87. if(this.isWin2000()) return 'Windows 2000';
  88. if(this.isWinXP()) return 'Windows XP';
  89. if(this.isWinServer2003()) return 'Windows Server 2003';
  90. if(this.isWinVista()) return 'Windows Vista';
  91. if(this.isWin7()) return 'Windows 7';
  92. //Nokia
  93. if(this.isNokia()) {
  94. if (this.ua.indexOf('Maemo Browser') != -1) return 'Maemo';
  95. if (this.ua.match('(SymbianOS)|(Symbian OS)')) return 'SymbianOS';
  96. if (this.ua.indexOf('Symbian') != -1) return 'Symbian';
  97. //return 'Nokia';
  98. }
  99. // BlackBerry
  100. if(this.isBlackBerry()) return 'BlackBerry OS';
  101. // Android
  102. if(this.isAndroid()) return 'Android';
  103. //linux
  104. if(this.isLinux()) return 'Linux';
  105. if(this.isSunOS()) return 'Sun OS';
  106. //iPhone
  107. if (this.isIphone()) return 'iOS';
  108. //iPad
  109. if (this.isIpad()) return 'iOS';
  110. //iPod
  111. if (this.isIpod()) return 'iOS';
  112. // zune
  113. //if (this.isZune()) return 'Zune';
  114. //macintosh
  115. if(this.isMacintosh()) {
  116. if((typeof navigator.oscpu != 'undefined') && (navigator.oscpu.indexOf('Mac OS')!=-1))
  117. return navigator.oscpu;
  118. return 'Macintosh';
  119. }
  120. //others
  121. if(this.isQNX()) return 'QNX';
  122. if(this.isBeOS()) return 'BeOS';
  123. if(this.isWebOS()) return 'webOS';
  124. return 'unknown';
  125. }
  126. };
  127. beef.regCmp('beef.net.os');