<commit_before>﻿using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Management;
using System.Threading;
using System.IO;
using System.IO.Compression;
using System.Net;
using System.Runtime.InteropServices;
using System.Text;
using RemoteZip;
using PlistCS;

namespace iKGD
{
	static class Utils
	{
		public static void ConsoleWrite(string str, ConsoleColor color)
		{
			ConsoleColor origColor = Console.ForegroundColor;
			Console.ForegroundColor = color;
			Console.Write(str);
			Console.ForegroundColor = origColor;
		}
		public static void ConsoleWriteLine(string str, ConsoleColor color)
		{
			ConsoleWrite(str + "\n", color);
		}
		
		public static void Delay(double SecondsToDelay)
		{
			DateAndTime.Now.AddSeconds(1.1574074074074073E-05);
			DateTime time = DateAndTime.Now.AddSeconds(1.1574074074074073E-05).AddSeconds(SecondsToDelay);
			while (DateTime.Compare(DateAndTime.Now, time) <= 0) { }
		}

		public static void CheckResources()
		{
			FileIO.Directory_Create(iKGD.TempDir);
			FileIO.Directory_Create(iKGD.Resources);
			if (!FileIO.File_Exists(iKGD.Resources + "dmg.exe"))
			{
				FileIO.Directory_Delete(iKGD.Resources);
				FileIO.SaveResourceToDisk("Resources.zip", iKGD.TempDir + "Resources.zip");
				UnzipAll(iKGD.TempDir + "Resources.zip", iKGD.Resources);
			}
			FileIO.Directory_Delete(iKGD.IPSWdir);
			FileIO.File_Delete(iKGD.TempDir + "Resources.zip");
		}

		public static void PwnDevice(string board)
		{
			Console.Write("Exploiting device with limera1n...");
			irecovery("-e");
			if (!FileIO.File_Exists(iKGD.TempDir + board + ".iBSS"))
			{
				Console.Write("\nDownloading iBSS for " + board + "...");
				Remote.DownloadImage("iBSS", board, iKGD.TempDir + board + ".iBSS");
			}
			else Delay(1);
			Console.Write("\nUploading iBSS...");
			irecovery_file(iKGD.TempDir + board + ".iBSS");
			Console.Write("\nWaiting for iBSS...");
			while (!SearchDeviceInMode("iBoot")) { };
			Console.Write("\nUploading iKGD iBSS payload...");
			irecovery_file(iKGD.Resources + board + ".ibss.payload");
			Console.WriteLine("\nExecuting iKGD iBSS payload...");
			irecovery_cmd("go");
			irecovery_cmd("go fbclear");
			irecovery_cmd("go nvram set iKGD true");
			irecovery_file(iKGD.Resources + "applelogo.img3");
			irecovery_cmd("setpicture 0");
			irecovery_cmd("bgcolor 0 0 0");
		}

		public static bool DeviceIsCompatible(string board)
		{
			switch (board)
			{
				case "n72ap":
				case "n18ap":
				case "n81ap":
				case "n88ap":
				case "n90ap":
				case "k48ap":
				case "k66ap":
					return true;
				default:
					return false;
			}<commit_msg>check for iBSS after downloading<commit_after>﻿using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Management;
using System.Threading;
using System.IO;
using System.IO.Compression;
using System.Net;
using System.Runtime.InteropServices;
using System.Text;
using RemoteZip;
using PlistCS;

namespace iKGD
{
	static class Utils
	{
		public static void ConsoleWrite(string str, ConsoleColor color)
		{
			ConsoleColor origColor = Console.ForegroundColor;
			Console.ForegroundColor = color;
			Console.Write(str);
			Console.ForegroundColor = origColor;
		}
		public static void ConsoleWriteLine(string str, ConsoleColor color)
		{
			ConsoleWrite(str + "\n", color);
		}
		
		public static void Delay(double SecondsToDelay)
		{
			DateAndTime.Now.AddSeconds(1.1574074074074073E-05);
			DateTime time = DateAndTime.Now.AddSeconds(1.1574074074074073E-05).AddSeconds(SecondsToDelay);
			while (DateTime.Compare(DateAndTime.Now, time) <= 0) { }
		}

		public static void CheckResources()
		{
			FileIO.Directory_Create(iKGD.TempDir);
			FileIO.Directory_Create(iKGD.Resources);
			if (!FileIO.File_Exists(iKGD.Resources + "dmg.exe"))
			{
				FileIO.Directory_Delete(iKGD.Resources);
				FileIO.SaveResourceToDisk("Resources.zip", iKGD.TempDir + "Resources.zip");
				UnzipAll(iKGD.TempDir + "Resources.zip", iKGD.Resources);
				FileIO.File_Delete(iKGD.TempDir + "Resources.zip");
			}
			FileIO.Directory_Delete(iKGD.IPSWdir);
		}

		public static void PwnDevice(string board)
		{
			Console.Write("Exploiting device with limera1n...");
			irecovery("-e");
			if (!FileIO.File_Exists(iKGD.TempDir + board + ".iBSS"))
			{
				Console.Write("\nERROR: Unable to download iBSS.");
				Remote.DownloadImage("iBSS", board, iKGD.TempDir + board + ".iBSS");
			}
			else Delay(1);
			if (!FileIO.File_Exists(iKGD.TempDir + board + ".iBSS"))
			{
				Console.Write("\nDownloading iBSS for " + board + "...");
				Environment.Exit((int)iKGD.ExitCode.NoInternetConnection);
			}
			Console.Write("\nUploading iBSS...");
			irecovery_file(iKGD.TempDir + board + ".iBSS");
			Console.Write("\nWaiting for iBSS...");
			while (!SearchDeviceInMode("iBoot")) { };
			Console.Write("\nUploading iKGD iBSS payload...");
			irecovery_file(iKGD.Resources + board + ".ibss.payload");
			Console.WriteLine("\nExecuting iKGD iBSS payload...");
			irecovery_cmd("go");
			irecovery_cmd("go fbclear");
			irecovery_cmd("go nvram set iKGD true");
			irecovery_file(iKGD.Resources + "applelogo.img3");
			irecovery_cmd("setpicture 0");
			irecovery_cmd("bgcolor 0 0 0");
		}

		public static bool DeviceIsCompatible(string board)
		{
			switch (board)
			{
				case "n72ap":
				case "n18ap":
				case "n81ap":
				case "n88ap":
				case "n90ap":
				case "k48ap":
				case "k66ap":
					return true;
				default:
					return false;
			}
{'fraction_non_alphanumeric': 0.13501144164759726, 'fraction_numerical': 0.021123041718007392, 'mean_word_length': 4.055160142348755, 'pattern_counts': {'":': 14, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '27720', 'n_tokens_mistral': 2301, 'n_tokens_neox': 1929, 'n_words': 378}