Giter Club home page Giter Club logo

networkinterceptor's Introduction

NetworkInterceptor

Simple framework to demo how we can intercept URLRequest in iOS Apps. This framework allows you to inspect the details of all outgoing requests from the app. This includes requests sent out by 3rd party framework like FacebookSDK, Google Analytics, etc. It is possible to use this framework to inspect and intercept App Store apps even on non-jailbroken devices.

Installation

NetworkInterceptor is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'NetworkInterceptor'

Main Components

How to use NetworkInterceptor

Example 1: Log all http/https requests using NSLog

let requestSniffers: [RequestSniffer] = [
    RequestSniffer(requestEvaluator: AnyHttpRequestEvaluator(), handlers: [
        SniffableRequestHandlerRegistrable.console(logginMode: .nslog).requestHandler()
    ])
]

let networkConfig = NetworkInterceptorConfig(requestSniffers: requestSniffers)
NetworkInterceptor.shared.setup(config: networkConfig)
NetworkInterceptor.shared.startRecording()

Example 2: For all requests that points to "www.antennahouse.com", redirect all matching requests to a custom URL

let requestRedirectors: [RequestRedirector] = [
    RequestRedirector(requestEvaluator: DomainHttpRequestEvaluator(domain: "www.antennahouse.com"),         
        redirectableRequestHandler: AlternateUrlRequestRedirector(url: URL(string: "https://www.rhodeshouse.ox.ac.uk/media/1002/sample-pdf-file.pdf")!))
]

let networkConfig = NetworkInterceptorConfig(requestRedirectors: requestRedirectors)
NetworkInterceptor.shared.setup(config: networkConfig)
NetworkInterceptor.shared.startRecording()

Request Evaluators available

AnyHttpRequestInterceptor.swift Intercepts all http and https requests

DomainHttpRequestEvaluator.swift Intercepts all http and https requests that matches a given doman URL

Sniffable Request Handlers available

ConsoleLoggerSniffableRequestHandler.swift Prints request in cURL format to the console

SlackSniffableRequestHandler.swift Sends the request in cURL format to a designated Slack channel. You are required to provide your own Slack Authentication Token and slack channel ID for this to work.

AlternateDomainSniffableRequestHandler.swift Sends the copy of the request to an alternate domain

Request Redirectors available

AlternateDomainRequestRedirector.swift Redirects request to a different domain.

AlternateUrlRequestRedirector.swift Requests request to a complete different URL

If you want to use this framework in iOS Device apps you do not own

  • Create a new Dynamic Framework Project and use NetworkInterceptor pod. We will only use this framework to start NetworkInterceptor recording.
  • Use Objective C to load code into memory. Refer to the example project in this repository.
static void __attribute__((constructor)) initialize(void)
  • Build the library using iphoneos architecture.
  • Get an .ipa file that does not have Digital Rights Management protection. You can download cracked .ipa from https://www.iphonecake.com
  • Inject both the NetworkInterceptor pod framework and your new Dynamic Framework into the .ipa using optool. You can also use the scripts from in this repository https://github.com/depoon/iOSDylibInjectionDemo. Make sure you included any necessary dependent framework or libraries.
  • Use Cydia Impactor to sideload the modified app.

networkinterceptor's People

Contributors

depoon avatar azubala avatar stevenarmandlee avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.