main.go 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. package yu_useragent
  2. import (
  3. "fmt"
  4. yu_rand "gogs.qqck.cn/s/tools/rand"
  5. )
  6. // ************************************************************************************************************************************ ChromePc
  7. func ChromePcWindows() string {
  8. Safari := rand_safari()
  9. Chrome := rand_chrome()
  10. WindowsNT := rand_windows_version()
  11. return fmt.Sprintf("Mozilla/5.0 (Windows NT %s; WOW64) AppleWebKit/%s (KHTML, like Gecko) Chrome/%s Safari/%s", WindowsNT, Safari, Chrome, Safari)
  12. }
  13. func ChromePcLinux() string {
  14. Safari := rand_safari()
  15. Chrome := rand_chrome()
  16. Linux := rand_linux_vertion()
  17. return fmt.Sprintf("Mozilla/5.0 (X11; %s) AppleWebKit/%s (KHTML, like Gecko) Chrome/%s Safari/%s", Linux, Safari, Chrome, Safari)
  18. }
  19. func ChromePcMac() string {
  20. Safari := rand_safari()
  21. Chrome := rand_chrome()
  22. mac_version := rand_mac_version()
  23. return fmt.Sprintf("Mozilla/5.0 (Macintosh; Intel Mac OS X %s) AppleWebKit/%s (KHTML, like Gecko) Chrome/%s Safari/%s", mac_version, Safari, Chrome, Safari)
  24. }
  25. func ChromePc() string {
  26. num := yu_rand.Uint31n(3)
  27. if num == 0 {
  28. return ChromePcWindows()
  29. } else if num == 1 {
  30. return ChromePcMac()
  31. } else {
  32. return ChromePcLinux()
  33. }
  34. }
  35. // ************************************************************************************************************************************ FirefoxPc
  36. func FirefoxPcWindows() string {
  37. Firefox := rand_firefox()
  38. WindowsNT := rand_windows_version()
  39. return fmt.Sprintf("Mozilla/5.0 (Windows NT %s; WOW64; rv:%s) Gecko/20100101 Firefox/%s", WindowsNT, Firefox, Firefox)
  40. }
  41. func FirefoxPcLinux() string {
  42. Firefox := rand_firefox()
  43. Linux := rand_linux_vertion()
  44. return fmt.Sprintf("Mozilla/5.0 (X11; %s; rv:%s) Gecko/20100101 Firefox/%s", Linux, Firefox, Firefox)
  45. }
  46. func FirefoxPcMac() string {
  47. Firefox := rand_firefox()
  48. mac_version := rand_mac_version()
  49. return fmt.Sprintf("Mozilla/5.0 (Macintosh; Intel Mac OS X %s; rv:%s) Gecko/20100101 Firefox/%s", mac_version, Firefox, Firefox)
  50. }
  51. func FirefoxPc() string {
  52. num := yu_rand.Uint31n(3)
  53. if num == 0 {
  54. return FirefoxPcWindows()
  55. } else if num == 1 {
  56. return FirefoxPcMac()
  57. } else {
  58. return FirefoxPcLinux()
  59. }
  60. }
  61. // ************************************************************************************************************************************ Pc
  62. func PcWindows() string {
  63. num := yu_rand.Uint31n(2)
  64. if num == 0 {
  65. return ChromePcWindows()
  66. } else {
  67. return FirefoxPcWindows()
  68. }
  69. }
  70. func PcLinux() string {
  71. num := yu_rand.Uint31n(2)
  72. if num == 0 {
  73. return ChromePcLinux()
  74. } else {
  75. return FirefoxPcLinux()
  76. }
  77. }
  78. func PcMac() string {
  79. num := yu_rand.Uint31n(2)
  80. if num == 0 {
  81. return ChromePcMac()
  82. } else {
  83. return FirefoxPcMac()
  84. }
  85. }
  86. func Pc() string {
  87. num := yu_rand.Uint31n(3)
  88. if num == 0 {
  89. return PcWindows()
  90. } else if num == 1 {
  91. return PcLinux()
  92. } else {
  93. return PcMac()
  94. }
  95. }
  96. // ************************************************************************************************************************************ Wechat
  97. func WechatAndroid() string {
  98. androidVersion := rand_android_version()
  99. androidPhone := rand_android_phone()
  100. Safari := rand_safari()
  101. Chrome := rand_chrome()
  102. XWEB := fmt.Sprintf("%d", yu_rand.IntMinMax(3317, 4317))
  103. MMWEBSDK := ""
  104. if yu_rand.Uint31n(2) == 0 {
  105. MMWEBSDK = fmt.Sprintf("20220%d0%d", yu_rand.IntMinMax(1, 9), yu_rand.IntMinMax(0, 9))
  106. } else {
  107. MMWEBSDK = fmt.Sprintf("20%d%d%d", yu_rand.IntMinMax(19, 21), yu_rand.IntMinMax(10, 12), yu_rand.IntMinMax(10, 26))
  108. }
  109. MMWEBID := fmt.Sprintf("%d", yu_rand.IntMinMax(8654, 9654))
  110. MicroMessenger := fmt.Sprintf("8.0.%d.%d(0x%d)", yu_rand.IntMinMax(15, 25), yu_rand.IntMinMax(1200, 2200), yu_rand.IntMinMax(27001937, 28001937))
  111. NetType := rand_nettype()
  112. // Mozilla/5.0 (Linux; Android 12; SM-G9980 Build/SP1A.210812.016; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/86.0.4240.99 XWEB/4317 MMWEBSDK/20220706 Mobile Safari/537.36 MMWEBID/9654 MicroMessenger/8.0.25.2200(0x28001937) WeChat/arm64 Weixin NetType/WIFI Language/zh_CN ABI/arm64
  113. return fmt.Sprintf("Mozilla/5.0 (Linux; Android %s; %s; wv) AppleWebKit/%s (KHTML, like Gecko) Version/4.0 Chrome/%s XWEB/%s MMWEBSDK/%s Mobile Safari/%s MMWEBID/%s MicroMessenger/%s WeChat/arm64 Weixin NetType/%s Language/zh_CN ABI/arm64",
  114. androidVersion, androidPhone, Safari, Chrome, XWEB, MMWEBSDK, Safari, MMWEBID, MicroMessenger, NetType,
  115. )
  116. }
  117. func WechatIphone() string {
  118. mac_version := rand_mac_version()
  119. Safari := rand_safari()
  120. j_Mobile := yu_rand.S0AZ(6)
  121. MicroMessenger := fmt.Sprintf("8.0.%d.%d(0x%d)", yu_rand.IntMinMax(15, 25), yu_rand.IntMinMax(1200, 2200), yu_rand.IntMinMax(27001937, 28001937))
  122. NetType := rand_nettype()
  123. // Mozilla/5.0 (iPhone; CPU iPhone OS 15_0_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.29(0x18001d30) NetType/WIFI Language/zh_CN
  124. return fmt.Sprintf("Mozilla/5.0 (iPhone; CPU iPhone OS %s like Mac OS X) AppleWebKit/%s (KHTML, like Gecko) Mobile/%s MicroMessenger/%s NetType/%s Language/zh_CN",
  125. mac_version, Safari, j_Mobile, MicroMessenger, NetType,
  126. )
  127. }
  128. // Wechat wechat 微信
  129. func Wechat() string {
  130. num := yu_rand.Uint31n(2)
  131. if num == 0 {
  132. return WechatAndroid()
  133. } else {
  134. return WechatIphone()
  135. }
  136. }
  137. // ************************************************************************************************************************************ Wechat
  138. func QQAndroid() string {
  139. androidVersion := rand_android_version()
  140. androidPhone := rand_android_phone()
  141. Safari := rand_safari()
  142. Chrome := rand_chrome()
  143. NetType := rand_nettype()
  144. GlobalDensityScale := fmt.Sprintf("0.%d", yu_rand.IntMinMax(95000004, 96000004))
  145. // Mozilla/5.0 (Linux; Android 12; SM-G9980 Build/SP1A.210812.016; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/99.0.4844.88 Mobile Safari/537.36 V1_AND_SQ_8.9.13_3350_YYB_D A_8091300 QQ/8.9.13.9280 NetType/WIFI WebP/0.4.1 Pixel/1080 StatusBarHeight/75 SimpleUISwitch/0 QQTheme/1000 InMagicWin/0 StudyMode/0 CurrentMode/0 CurrentFontScale/1.0 GlobalDensityScale/0.96000004 AppId/537137213 AllowLandscape/false
  146. return fmt.Sprintf("Mozilla/5.0 (Linux; Android %s; %s; wv) AppleWebKit/%s (KHTML, like Gecko) Version/4.0 Chrome/%s Mobile Safari/%s V1_AND_SQ_8.9.13_3350_YYB_D A_8091300 QQ/8.9.13.9280 NetType/%s WebP/0.4.1 Pixel/1080 StatusBarHeight/75 SimpleUISwitch/0 QQTheme/1000 InMagicWin/0 StudyMode/0 CurrentMode/0 CurrentFontScale/1.0 GlobalDensityScale/%s AppId/537137213 AllowLandscape/false",
  147. androidVersion, androidPhone, Safari, Chrome, Safari, NetType, GlobalDensityScale,
  148. )
  149. }
  150. func QQIphone() string {
  151. mac_version := rand_mac_version()
  152. Safari := rand_safari()
  153. j_Mobile := yu_rand.S0AZ(6)
  154. Apple := rand_iphone_phone()
  155. NetType := rand_nettype()
  156. // Mozilla/5.0 (iPhone; CPU iPhone OS 15_0_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/19A404 QQ/8.5.5.648 V1_IPH_SQ_8.5.5_1_APP_A Pixel/1170 MiniAppEnable SimpleUISwitch/0 QQTheme/1000 Core/WKWebView Device/Apple(iPhone 12 Pro) NetType/WIFI QBWebViewType/1 WKType/1
  157. return fmt.Sprintf("Mozilla/5.0 (iPhone; CPU iPhone OS %s like Mac OS X) AppleWebKit/%s (KHTML, like Gecko) Mobile/%s QQ/8.9.13.9280 V1_IPH_SQ_8.9.13_3350_APP_A Pixel/1170 MiniAppEnable SimpleUISwitch/0 QQTheme/1000 Core/WKWebView Device/Apple(%s) NetType/%s QBWebViewType/1 WKType/1",
  158. mac_version, Safari, j_Mobile, Apple, NetType,
  159. )
  160. }
  161. // QQ QQ
  162. func QQ() string {
  163. num := yu_rand.Uint31n(2)
  164. if num == 0 {
  165. return QQAndroid()
  166. } else {
  167. return QQIphone()
  168. }
  169. }
  170. // ************************************************************************************************************************************ Android
  171. // MobileAndroid android手机无线端
  172. func MobileAndroid() string {
  173. num := yu_rand.Uint31n(2)
  174. if num == 0 {
  175. return WechatAndroid()
  176. } else {
  177. return QQAndroid()
  178. }
  179. }
  180. // ************************************************************************************************************************************ Iphone
  181. // MobileIphone iphone手机无线端
  182. func MobileIphone() string {
  183. num := yu_rand.Uint31n(2)
  184. if num == 0 {
  185. return WechatIphone()
  186. } else {
  187. return QQIphone()
  188. }
  189. }
  190. // ************************************************************************************************************************************ Wap
  191. // Mobile 手机端
  192. func Mobile() string {
  193. num := yu_rand.Uint31n(2)
  194. if num == 0 {
  195. return MobileAndroid()
  196. } else {
  197. return MobileIphone()
  198. }
  199. }
  200. // ************************************************************************************************************************************ Rand
  201. // Rand 随机
  202. func Rand() string {
  203. num := yu_rand.Uint31n(2)
  204. if num == 0 {
  205. return Pc()
  206. } else {
  207. return Mobile()
  208. }
  209. }