Permalink
Browse files

Initial Commit

  • Loading branch information...
0 parents commit a3e9945529dc112c7f1067450c6cad945030eb48 System Administrator committed Dec 23, 2011
@@ -0,0 +1,9 @@
+all: package install
+
+VERSION=$(shell cat src/DEBIAN/control | grep Version | cut -d " " -f 2)
+
+package:
+ dpkg-deb -b src CDevReporter-$(VERSION).deb
+
+install:
+ dpkg -i CDevReporter-$(VERSION).deb
3 TODO
@@ -0,0 +1,3 @@
+FIX: Remove hosts in prerm
+FIX: Move host opperations to main script instead of preandpost inst/rm then make it run as root (has to)
+FIX: Description to have the legal stuff in it. (Like that it's submitting in the background)
@@ -0,0 +1,10 @@
+Package: com.chronic-dev.CDevReporter
+Name: Crash Reporter
+Version: 1.0.0
+Architecture: iphoneos-arm
+Description: somebody else put this here cuz i'm way to lazy. and while you're at it could you fix the prefs one too. Just make it sound nice.
+Homepage: http://chronic-dev.org
+Maintainer: Luke Young (innoying) <cydia@innoying.com>
+Author: Luke Young (innoying) <cydia@innoying.com>
+Depends: preferenceloader, coreutils, com.ericasadun.utilities, net.tootallnate.node, com.innoying.ecid
+Section: System
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+echo "127.0.0.1 iphonesubmissions.apple.com" >> /etc/hosts
+
+mkdir /usr/local/chronic-dev.CDevReporter
+pushd /usr/local/chronic-dev.CDevReporter
+ npm install stalker
+popd
+
+launchctl load /System/Library/LaunchDaemons/com.chronic-dev.CDevReporter.plist
+
+
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+rm -rf /usr/local/chronic-dev.CDevReporter/
+
+launchctl unload /System/Library/LaunchDaemons/com.chronic-dev.CDevReporter.plist
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>entry</key>
+ <dict>
+ <key>cell</key>
+ <string>PSLinkCell</string>
+ <key>label</key>
+ <string>Crash Reporter</string>
+ </dict>
+ <key>items</key>
+ <array>
+ <dict>
+ <key>cell</key>
+ <string>PSGroupCell</string>
+ <key>footerText</key>
+ <string>The CDevReporter is a application created by the Chronic-Dev team that sends your crash reports to the Chronic-Dev team in the hope that they can glean information about possible exploits to use in future jailbreaks. This app will run in the background and automatically submit crash-reports to the chronic-dev team. If you are on a mobile network, it WILL use data (although not much). If you do not want this, please uninstall this app immediately or disable it above. This jb version of the app is a port by innoying and is in no way guaranteed to work. Nor is innoying or anybody else responsible for issues with this application or results of using it.</string>
+ </dict>
+ <dict>
+ <key>cell</key>
+ <string>PSSwitchCell</string>
+ <key>default</key>
+ <true/>
+ <key>defaults</key>
+ <string>com.chronic-dev.CDevReporter</string>
+ <key>key</key>
+ <string>enabled</string>
+ <key>label</key>
+ <string>Enabled</string>
+ </dict>
+ </array>
+ <key>title</key>
+ <string>Crash Reporter</string>
+</dict>
+</plist>
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>Label</key>
+ <string>com.chronic-dev.CDevReporter</string>
+ <key>ProgramArguments</key>
+ <array>
+ <string>/usr/local/bin/node</string>
+ <string>/usr/local/chronic-dev.CDevReporter/launch.js</string>
+ </array>
+ <key>RunAtLoad</key>
+ <true/>
+</dict>
+</plist>
@@ -0,0 +1,212 @@
+#!/usr/bin/env node
+
+var stalker = require("stalker");
+var zlib = require('zlib');
+var path = require('path');
+var http = require('http');
+var fs = require("fs");
+var exec = require('child_process').exec;
+
+var enabled = false;
+var ecid = "";
+var loc = "/var/mobile/Library/Logs/CrashReporter/";
+
+//Trim function
+String.prototype.trim = function() {
+ return this.replace(/^\s+|\s+$/g,"");
+}
+
+//Watch the pref file for changes
+fs.watchFile('/var/mobile/Library/Preferences/com.chronic-dev.CDevReporter.plist', function (curr, prev) {
+ updateECID();
+});
+
+//Update the enabled status
+function updateEnabled(cb){
+ //Log
+ log("Checking/Changing enable status");
+ //Get the pref value
+ exec('plutil -key "enabled" /var/mobile/Library/Preferences/com.chronic-dev.CDevReporter.plist', function (err, enabledvalue, stderr) {
+ //Log
+ log("Read enabled value of: "+(enabledvalue.trim() == "1"));
+ //If enabled
+ enabled = (enabledvalue.trim() == "1") ? true : false;
+ //run the cb
+ cb();
+ });
+}
+
+//Begin logging
+log("Launched");
+
+//Update the ecid value and launch
+function updateECID(){
+ //Using com.innoying.ecid execute ECID to get the hex ecid
+ exec('ECID', function (err, hexecid, stderr) {
+ ecid = parseInt(hexecid, 16);
+ log("Got ECID: "+ecid)
+ //Check if the reported is enabled
+ updateEnabled(function(){
+ //Log
+ log("Launching.");
+ fs.readdir(loc, function(err, files){
+ files.forEach(function(file, index){
+ files[index] = loc + file;
+ });
+ //Run handle function
+ handleFiles(err, files, ecid);
+ //Log
+ log("Launched.");
+ });
+ });
+ });
+}
+
+//Multi-part form stuff----------------------------------------------------------------------------------------------
+function EncodeFieldPart(boundary,name,value) {
+ var return_part = "--" + boundary + "\r\n";
+ return_part += "Content-Disposition: form-data; name=\"" + name + "\"\r\n\r\n";
+ return_part += value + "\r\n";
+ return return_part;
+}
+
+function EncodeFilePart(boundary,type,name,filename) {
+ var return_part = "--" + boundary + "\r\n";
+ return_part += "Content-Disposition: form-data; name=\"" + name + "\"; filename=\"" + filename + "\"\r\n";
+ return_part += "Content-Type: " + type + "\r\n\r\n";
+ return return_part;
+}
+//-------------------------------------------------------------------------------------------------------------------
+
+//Pad numbers with zeros function
+function pad(number, length) {
+ var str = '' + number;
+ while (str.length < length) {
+ str = '0' + str;
+ }
+ return str;
+}
+
+//Interval Check
+setInterval(updateECID, 3600000);
+
+//Start stalker on the passed path.
+stalker.watch(loc, {buffer: 60000}, updateECID);
+
+//Handle the files
+function handleFiles(err, files, ecid){
+ if(!enabled){
+ //Log
+ log("Not continuing due to user disabling CDevReporter")
+ //Exit
+ return false;
+ }
+ //Log the number of files
+ log( "Found " + files.length + " new file(s)." );
+ //Create a boundary object
+ var boundary = Math.random();
+ //Create a request object
+ var request = [];
+ //Add ecid to request
+ request.push(new Buffer(EncodeFieldPart(boundary, 'ecid', ecid+""), 'ascii'));
+ //Loop for each file
+ files.forEach(function (file, index) {
+ //Log
+ log( "Found file " + file );
+ //Gzip ALL THE FILES!!! (actually one at a time)
+ zlib.gzip(fs.readFileSync(file), function(err, result){
+ //Log
+ log( "Gzipped " + file );
+ //Create a temp array to hold the file data
+ var temp = [];
+ //Add to the form
+ temp.push(new Buffer(EncodeFilePart(boundary, 'application/x-gzip', "file"+pad(index, 4), path.basename(file)+".gz"), 'ascii'));
+ temp.push(result);
+ temp.push(new Buffer("\r\n--" + boundary + "--\r\n", 'ascii'));
+ //Add temp to the end of request
+ request.push.apply(request, temp);
+ //If this is the last
+ if(files.length == ((request.length-1)/3)){
+ //Log
+ log("Attempting Upload");
+ //Upload
+ upload(request, boundary, files);
+ }
+ });
+ });
+}
+
+//Upload function
+function upload(request, boundary, files){
+ //Create a length variable
+ var length = 0;
+ //For each part of the request array
+ for(var i = 0; i < request.length; i++) {
+ //Add the length to the total
+ length += request[i].length;
+ }
+ //Setup the post options
+ var post_options = {
+ host: 'battleground-fw2ckdbmqg.elasticbeanstalk.com',
+ port: '80',
+ path: '/upload.jsp',
+ method: 'POST',
+ headers : {
+ 'Content-Type' : 'multipart/form-data; boundary=' + boundary,
+ 'Content-Length' : length
+ }
+ };
+ //Create a post request
+ var post_request = http.request(post_options, function(response){
+ //Make sure this is utf8
+ response.setEncoding('utf8');
+ //Create a data var
+ var data = "";
+ //On data response
+ response.on('data', function(chunk){
+ //Append chunk to data
+ data += chunk;
+ });
+ //On the request ending
+ response.on('end', function(){
+ //If the upload was successful
+ if(response.statusCode == 200 && data.trim() == "SUCCESS"){
+ //Log
+ log("Success uploading " + files.length + " file(s).");
+ //For each file
+ files.forEach(function(file){
+ log("Deleting "+file);
+ //Delete the file
+ fs.unlink(file);
+ });
+ log("Done. Sleeping.");
+ }else{
+ //Display the errors
+ log("Error uploading the server replied:");
+ log(data);
+ log("With status code: " + response.statusCode)
+ }
+ });
+ });
+ //For each part of the request
+ for (var i = 0; i < request.length; i++) {
+ //Send it
+ post_request.write(request[i]);
+ }
+ //End the post
+ post_request.end();
+}
+
+//Log object
+
+
+//Log function
+function log(string){
+ var logfs = fs.createWriteStream('/var/mobile/Library/Logs/CDevReporter.txt', {'flags': 'a'});
+ string = string + "";
+ console.log(string);
+ logfs.write(new Date().getTime()+": "+string+"\n");
+}
+
+//Start
+updateECID();
No changes.

0 comments on commit a3e9945

Please sign in to comment.