コード例 #1
0
        /// <summary>
        /// Generates the keys and calls JEE service (recursive function)
        /// </summary>
        public static void GenKeys(char[] set, string content, string key, int n, int k, string name, MSG msg)
        {
            if (Utils.FOUND_SECRET == false)
            {
                if (k == 0)
                {
                    if (Utils.FOUND_SECRET == false)
                    {
                        string         r   = Decrypt(content, key);
                        JEEService.msg res = Utils.ToJEEMessage(msg);
                        System.Text.UnicodeEncoding encoding = new System.Text.UnicodeEncoding();
                        byte[] rr = encoding.GetBytes(r);
                        //sbyte[] x = (sbyte[])Array.ConvertAll(rr, b => unchecked((sbyte)b));
                        string rrr = "";
                        for (int i = 0; i < rr.Length; i++)
                        {
                            if (i == rr.Length - 1)
                            {
                                rrr += rr[i].ToString();
                            }
                            else
                            {
                                rrr += rr[i].ToString() + ",";
                            }
                        }


                        res.data = new object[] { name, rrr, key };

                        try {
                            Console.WriteLine(key);
                            svc.fileCheck(res);
                        } catch (FaultException ex) {
                            Console.WriteLine(ex);
                        }
                    }

                    return;
                }

                /*for (int i=0; i<n; i++) {
                 *  if (Utils.FOUND_SECRET) break;
                 *  string newPrefix = key + set[i];
                 *  GenKeys(set, content, newPrefix, n, k - 1, name, msg);
                 * }*/
                Parallel.For(0, n, (i, state) => {
                    if (Utils.FOUND_SECRET)
                    {
                        state.Break();
                    }
                    string newPrefix = key + set[i];
                    GenKeys(set, content, newPrefix, n, k - 1, name, msg);
                });
            }
        }
コード例 #2
0
 /// <summary>
 /// Transform a MSG object in JEEService msg object to make it understandable by JEE
 /// </summary>
 /// <param name="msg">The MSG object sent by the client</param>
 /// <returns>The JEEService msg object</returns>
 public static JEEService.msg ToJEEMessage(MSG msg)
 {
     JEEService.msg res = new JEEService.msg();
     res.appVersion       = msg.appVersion;
     res.data             = msg.data;
     res.info             = msg.info;
     res.operationName    = msg.operationName;
     res.operationVersion = msg.operationVersion;
     res.statutOp         = msg.statut_Op;
     res.tokenApp         = msg.tokenApp;
     res.tokenUser        = msg.tokenUser;
     return(res);
 }