captcha.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. package common
  2. import (
  3. "bytes"
  4. "encoding/json"
  5. "git.listensoft.net/tool/jspkit/common/lxhttp"
  6. "git.listensoft.net/tool/jspkit/logger"
  7. "io"
  8. "net/http"
  9. "strings"
  10. "time"
  11. "github.com/ysmood/leakless/pkg/utils"
  12. )
  13. func GetMobileCaptcha(mobile string) string {
  14. client := &http.Client{
  15. Timeout: 60 * time.Second,
  16. }
  17. defer client.CloseIdleConnections()
  18. resp, err := client.Post("https://public.listensoft.net/api/getTaxSms", "application/json", strings.NewReader(`{"mobile":"`+mobile+`"}`))
  19. if err != nil {
  20. return ""
  21. }
  22. body, err := io.ReadAll(resp.Body)
  23. if err != nil {
  24. return ""
  25. }
  26. logger.Info("获取到的手机验证码: " + string(body))
  27. return string(body)
  28. }
  29. type GsnvYzm struct {
  30. ID uint `json:"id"`
  31. Code string `json:"code"`
  32. }
  33. // 获取工商年报验证码 code验证码 id正确后需要上传纳税人识别号
  34. // 数组返回最多四个验证码 空或者都不对报错
  35. // 验证码正确后调用上传纳税人识别号接口,两小时内返回都是第一个
  36. func GetGsnbMobileCaptcha(mobile string, taxNo string) []GsnvYzm {
  37. utils.Sleep(60)
  38. client := &http.Client{
  39. Timeout: 60 * time.Second,
  40. }
  41. defer client.CloseIdleConnections()
  42. resp, err := client.Post("https://public.listensoft.net/api/getGsSms", "application/json", strings.NewReader(`{"mobile":"`+mobile+`","taxNo":"`+taxNo+`"}`))
  43. if err != nil {
  44. return []GsnvYzm{}
  45. }
  46. body, err := io.ReadAll(resp.Body)
  47. if err != nil {
  48. return []GsnvYzm{}
  49. }
  50. list := []GsnvYzm{}
  51. json.Unmarshal(body, &list)
  52. return list
  53. }
  54. // 上传工商年报验证码对应的纳税人识别号 code验证码 id 正确后需要上传纳税人识别号
  55. func UploadGsnbMobileCaptcha(id uint, taxNo string) {
  56. utils.Sleep(60)
  57. client := &http.Client{
  58. Timeout: 60 * time.Second,
  59. }
  60. defer client.CloseIdleConnections()
  61. param := map[string]interface{}{
  62. "id": id,
  63. "taxNo": taxNo,
  64. }
  65. bys, _ := json.Marshal(param)
  66. client.Post("https://public.listensoft.net/api/uploadGsSms", "application/json", bytes.NewReader(bys))
  67. // _, err := io.ReadAll(resp.Body)
  68. // if err != nil {
  69. // return
  70. // }
  71. }
  72. // area--》传验证码中的地区关键字
  73. func GetMobileCaptchaForArea(mobile, area string) string {
  74. resp, err := http.Post("https://public.listensoft.net/api/getTaxSms", "application/json", strings.NewReader(`{"mobile":"`+mobile+`","area": "`+area+`"}`))
  75. if err != nil {
  76. return ""
  77. }
  78. body, err := io.ReadAll(resp.Body)
  79. if err != nil {
  80. return ""
  81. }
  82. logger.Info("获取到的手机验证码: " + string(body))
  83. return string(body)
  84. }
  85. func GetMobileCaptchaForJiangSu(mobile string) (string, error) {
  86. c := lxhttp.NewHttpClient()
  87. req, err := http.NewRequest("POST", "https://public.listensoft.net/api/getTaxSms", strings.NewReader(`{"mobile":"`+mobile+`"}`))
  88. if err != nil {
  89. logger.Info(err)
  90. return "", err
  91. }
  92. req.Header.Set("Content-Type", "application/json")
  93. resp, err := c.Do(req)
  94. if err != nil {
  95. logger.Info(err)
  96. return "", err
  97. }
  98. body, err := io.ReadAll(resp.Body)
  99. if err != nil {
  100. return "", err
  101. }
  102. logger.Info("获取到的手机验证码: " + string(body))
  103. return string(body), nil
  104. }
  105. // func GetMobileCaptchaForSiChuan(mobile, remark string) string {
  106. // resp, err := http.Post("https://public.listensoft.net/api/getTaxSms", "application/json",
  107. // strings.NewReader(`{"mobile":"`+mobile+`","remark":"`+remark+`"}`))
  108. // if err != nil {
  109. // return ""
  110. // }
  111. // body, err := io.ReadAll(resp.Body)
  112. // if err != nil {
  113. // return ""
  114. // }
  115. // return string(body)
  116. // }