samedi 1 mai 2021

Akamai 403 acced denied

I'm trying to write a code that login into Zalando website. When I do login request AKAMAI GHOST server block me with error 403 access denied.

Below the code, someone can help me ?

import time
import requests
from bs4 import BeautifulSoup
import json
import logging

logging.basicConfig(level=logging.DEBUG)


# all cookies received will be stored in the session object
s = requests.Session()

url='https://www.zalando.it'

####### First request function ##################################################################
headers = {
    'authority': 'www.zalando.it',
    'pragma': 'no-cache',
    'cache-control': 'no-cache',
    'sec-ch-ua': '"Chromium";v="88", "Google Chrome";v="88", ";Not A Brand";v="99"',
    'sec-ch-ua-mobile': '?0',
    'upgrade-insecure-requests': '1',
    'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.192 Safari/537.36',
    '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.9',
    'sec-fetch-site': 'none',
    'sec-fetch-mode': 'navigate',
    'sec-fetch-user': '?1',
    'sec-fetch-dest': 'document',
    'accept-language': 'it',
}
response = s.get(url, headers=headers)
st_code=response.status_code
url_text=response.text
resp_header_fr=response.headers
ck=s.cookies
#print(ck)
#print(st_code)
##################################################################################################

######### extract token
cookies_dictionary = ck.get_dict()
json_object = json.dumps(cookies_dictionary)
d2 = json.loads(json_object)

#print('token....')
#print('lets go!')
token=(d2["frsx"])
#print(token)


########### extract il client-id
json_object = json.dumps(cookies_dictionary)
d2 = json.loads(json_object)

#print('Client-id....')
#print(d2["Zalando-Client-Id"])
#print('lets go!')
client_id=(d2["Zalando-Client-Id"])
##############################################################################

## Delay 2 sec
time.sleep(2)

##############################################################################

####### Login request function ###################################################################
headers = {
    'authority': 'www.zalando.it',
    'sec-ch-ua': '" Not A;Brand";v="99", "Chromium";v="90", "Google Chrome";v="90"',
    'x-xsrf-token': token,
    'x-zalando-render-page-uri': '/login',
    'x-zalando-client-id': client_id,
    'content-type': 'application/json',
    'x-zalando-request-uri': '/login',
    'accept': 'application/json',
    'x-zalando-toggle-label': 'THE_LABEL_IS_ENABLED',
    'sec-ch-ua-mobile': '?0',
    'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36',
    'origin': 'https://www.zalando.it',
    'sec-fetch-site': 'same-origin',
    'sec-fetch-mode': 'cors',
    'sec-fetch-dest': 'empty',
    'referer': 'https://www.zalando.it/login',
    'accept-language': 'en-GB,en;q=0.9',
}
data = '{"username":"Email@gmail.com","password":"Password!","wnaMode":"modal"}'
url_login = 'https://www.zalando.it/api/reef/login'
response2 = s.post(url_login, headers=headers, data=data)
st_code=response2.status_code
ck2=s.cookies
url02_text=response2.text
resp_header_login=response2.headers

#Print cookie and response code

#print(ck)
print(st_code)
print(url02_text)
#print(resp_header_login)

if I run the same code with cookie and token taken from chrome browser, it work. I thin that Akamai detect that its not a web chrome session and not allow me to login.




Unable to connect mysql - web application

Ihello, i am using webmin to administer my linux server. I have a problem with MySQL, I created a user by assigning rights. But I can't log in with my web app.

database permission

user permission

error in web application

bind-addres = 0.0.0.0

Thanks for your help




When i'm trying to start Standard web app(Java) which is created by Intellij idea(TomcatServer) and go to servlet "url" i get error 404

I'm trying to start web app created by Intellij idea and go to url that should invoke the servlet class i get error 404. I use Apache Tomcat 10.0.5 and have following project structure

Class that named HelloServlet

@WebServlet(name = "helloServlet", value = "/hello-servlet")
public class HelloServlet extends HttpServlet {
    private String message;

    public void init() {
        message = "Hello World!";
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        response.setContentType("text/html");

        // Hello
        PrintWriter out = response.getWriter();
        out.println("<html><body>");
        out.println("<h1>" + message + "</h1>");
        out.println("</body></html>");
    }

    public void destroy() {
    }
}

Index.jsp

<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <title>JSP - Hello World</title>
</head>
<body>
<h1><%= "Hello World!" %>
</h1>
<br/>
<a href="hello-servlet">Hello Servlet</a>
</body>
</html>

When i'm runnig project i go to url and get what i want enter image description here But if i click on "HelloServlet" that should invoke servlet class i get this error

enter image description here enter image description here

I haven't changed anything in this project




Is using token when login really stateless?

I'm studying about how to authenticate user in web application. Apparently, one of advantages of using token is it doesn't need to be stored in server(stateless), however given security or invalidation, shouldn't refresh token be stored somewhere like Redis to determine it is invalid token(ex : user logged out) or not ?

Thanks in advance.




Browser-side JS: File System API vs File System Access API?

There was a File System API but shown as deprecated now:
https://developer.mozilla.org/en-US/docs/Web/API/Window/requestFileSystem

There is now another, File System Access API:
https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API

What happened to the old API and why was it discontinued? Should the new File System Access API be stable in all common browsers?




go invalid memory address or nil pointer dereference

Hi i'm trying to use IBM cloudant DB in go I copied codes from IBM official document

productsDoc := cloudantv1.Document{
    ID: core.StringPtr("small-appliances:1000042"),
}
productsDoc.SetProperty("type", "product")
productsDoc.SetProperty("productid", "1000042")
productsDoc.SetProperty("brand", "Salter")
productsDoc.SetProperty("name", "Digital Kitchen Scales")
productsDoc.SetProperty("description", "Slim Colourful Design Electronic Cooking Appliance for Home / Kitchen, Weigh up to 5kg + Aquatronic for Liquids ml + fl. oz. 15Yr Guarantee - Green")
productsDoc.SetProperty("price", 14.99)
productsDoc.SetProperty("image", "assets/img/0gmsnghhew.jpg")

postDocumentOptions := service.NewPostDocumentOptions(
    "users",
)
postDocumentOptions.SetDocument(&productsDoc)
service.PostDocument(postDocumentOptions)

Then i ran the code But i got this error runtime error: invalid memory address or nil pointer dereference it says this code is the problem service.PostDocument(postDocumentOptions) But i don't know why it is a problem please help me thank you

enter image description here




How do I display images from Google Drive on a react front-end website?

I want to upload some photos in my Google Drive and would like me to display those photos. I'm actually using React.js right now and I'm really new to programming. I just wanna display the photos and have the specific date related to the photos. I'm searching on google and youtube and I still have no clear answers.