Created
August 14, 2019 08:44
-
-
Save leonjza/7b339fe75b23faa5b9f00fbd6de4f463 to your computer and use it in GitHub Desktop.
objection Jenkins pipeline steps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Build the target application (PewPew is the name for my app) | |
xcodebuild build build -workspace PewPew.xcworkspace -scheme PewPew -sdk iphonesimulator12.2 | |
# | |
# iOS Simulator setup | |
# | |
echo "Simulator Setup" | |
echo "===============" | |
echo "Using iPhone 7 with UUID..." | |
xcrun simctl list -j | jq -r ".devices | to_entries[] | .value[] | select(.name==\"iPhone 7\") | .udid" | |
echo "Checking if we have booted simulators..." | |
if [[ $(xcrun simctl list -j | jq -r ".devices | to_entries[] | .value[] | select(.state==\"Booted\") | .udid") ]]; then | |
echo "There are running simulators. Stopping 'em" | |
xcrun simctl shutdown `xcrun simctl list -j | jq -r ".devices | to_entries[] | .value[] | select(.state!=\"Shutdown\") | .udid"` | |
else | |
echo "There are no running simulators" | |
fi | |
echo "Starting an iPhone 7 simulator..." | |
xcrun simctl boot `xcrun simctl list -j | jq -r ".devices | to_entries[] | .value[] | select(.name==\"iPhone 7\") | .udid"` | |
echo "Installing built app" | |
xcrun simctl install `xcrun simctl list -j | jq -r ".devices | to_entries[] | .value[] | select(.state==\"Booted\") | .udid"` `xcodebuild -workspace PewPew.xcworkspace -scheme PewPew -showBuildSettings -json | jq -r ".[0].buildSettings.TARGET_BUILD_DIR" | sed -e 's/Release-iphoneos/Debug-iphonesimulator\/PewPew.app/'` | |
echo "Launching application" | |
xcrun simctl launch `xcrun simctl list -j | jq -r ".devices | to_entries[] | .value[] | select(.state==\"Booted\") | .udid"` za.sensepost.ipewpew | |
# | |
# objection API start | |
# | |
echo "objection" | |
echo "=========" | |
screen -S "JENKINS_TEST" -d -m bash -c "objection -N explore -a" | |
echo "Giving the API a few seconds to settle" | |
sleep 5 | |
# | |
# Perform the tests | |
# | |
echo "instrumentation tests" | |
echo "=====================" | |
# Testing for PIE | |
BINARY_SAFETY=$(curl -s \ | |
-H "Content-Type: application/json" \ | |
-X GET http://127.0.0.1:8888/rpc/invoke/iosBinaryInfo | jq ".[] | select(.type==\"execute\")") | |
if [ ! "$(echo $BINARY_SAFETY | jq '.pie')" = true ] ; then | |
echo "Main executable does NOT have PIE enabled" | |
exit 1 | |
fi | |
if [ ! "$(echo $BINARY_SAFETY | jq '.canary')" = true ] ; then | |
echo "Main executable does NOT have Stack canaries enabled" | |
exit 1 | |
fi | |
if [ ! "$(echo $BINARY_SAFETY | jq '.arc')" = true ] ; then | |
echo "Main executable does NOT have Reference Counting enabled" | |
exit 1 | |
fi | |
# | |
# Cleanup | |
# | |
echo "cleaning up" | |
echo "========" | |
xcrun simctl terminate `xcrun simctl list -j | jq -r ".devices | to_entries[] | .value[] | select(.state==\"Booted\") | .udid"` za.sensepost.ipewpew | |
xcrun simctl shutdown `xcrun simctl list -j | jq -r ".devices | to_entries[] | .value[] | select(.state!=\"Shutdown\") | .udid"` | |
screen -S "JENKINS_TEST" -X quit | |
xcodebuild clean |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment