0

I am trying to capture network traffic of iPhone app (using WebdriverIO test framework) using https://www.npmjs.com/package/http-mitm-proxy but its not working for me. (there are no logs captured but when tried manually by installing mitmproxy, logs are coming in terminal)

Tried following steps, but no success:-

a) Have installed proxy certificate (generated by http-mitm-proxy) on iphone.

b) Set wifi proxy setting on iphone (server address : macbook ip, port : 8081)

Code:-

import {Proxy} from "http-mitm-proxy";

describe('Calculate perf data', () => {
it('Calculate perf data', async () => 
{
    const proxy = new Proxy();
    proxy.onError((ctx, err) => {
        console.error('Proxy error:', err);
    });

    proxy.onRequest((ctx, callback) => {
        console.log('Proxy request:', ctx.clientToProxyRequest.headers.host, ctx.clientToProxyRequest.url);
        ctx.use(Proxy.gunzip);

        ctx.onResponseData((ctx, chunk, callback) => {
            console.log('Response data:', chunk.toString());
            return callback(null, chunk);
        });

        return callback();
    });

    proxy.listen({port: 8081}, () => {
        console.log('Proxy server is listening on port 8081');
    });

    console.log('begin listening on 8081')

    const email = "///XCUIElementTypeTextField";
    const pwd = "//XCUIElementTypeSecureTextField[@name=\"text-input-outlined\"]";

    const login = "//XCUIElementTypeButton[@name=\"button\"]";
    (await $(email).setValue("[email protected]"));
    (await $(pwd).setValue("xyz"));
    (await $(login).click());

})
})
2
  • Please edit your question and define "its not working for me". What exactly isn't working? Are you getting an error or an unexpected result? At what point in your code is that problem or error occurring? We need to know the details of "not working" in order to understand your problem. Commented Nov 19, 2024 at 18:56
  • Make sure you installed the correct certs otherwise it will not work (Read their section on ssl). You can also look at mitmproxy.org as an alternative. Commented Nov 19, 2024 at 20:31

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.