Showing posts with label Hacking. Show all posts
Showing posts with label Hacking. Show all posts

Monday, August 24, 2015

PfishBot:Autophishing: The Request: Part I

So we will jump back to messaging in a minute but first we need to go here:

https://m.facebook.com/findfriends/browser/

Where we can "find friends".


Now the JS here is really simple whip open console and we can do a test before we loop it


Successful

And now we use the location.reload(), this will reset the suggestions:



 and now time to automate:

1
2
3
4
5
6
7
8
9
while(1){

document.querySelectorAll("button[type='submit']")[0].click();
  setTimeout(func, 3000);
  function func(){
location.reload();
}
  
}
It may be best to use a for loop though but it works. You actually need a significant delay apparently facebook thinks the public is rather slow. So put as long as you need, a minute so that they never try to block you might be a good idea.

PfishBot:Auto Phishing: Messaging: Part I

Phishing is the process of creating fake IDs and making them appear real. I decided to automate the whole process from replying to messages to adding "friends".

First thing to do is set up the messaging system as this is doubtless to be the most difficult part.

First we find a weakpoint in the site to launch from, in the case of Facebook the page with the most functionality and least html to scan and possibly parse is:


Now I should mention that in order to create a fake account you will probably need a phone number, and getting past this is just not worth it as free applications such as text+ work just fine. Or use a payphone. I don't care.

Great now finding the  message box name is easy:

"composerInput"

however the button for send is a bit more dynamic, it changes each time and there is a convoluted js and php script which hides it unless text was dynamically entered". Two ways past, JS or .Net.


JS

So the JS code is real simple:

Inspect the text box. Lets say for our example it is running under the ID of "u_0_5":


 The errors happened because of button ID change. Now we can text the click again, once we have entered text so as to fake the button(we will get to doing this automatically shortly):
So our code is:

1
2
3
4
5
6
7
8
var content = document.body.textContent || document.body.innerText;
var hasText = content.indexOf("Way to go")!==-1;
if(hasText){
   setTimeout(function(){
       document.getElementById('composerInput').value="Second Check";
    document.getElementById('u_3p_5').click();
   },5000);
}

But that really is not too useful because we have not been able to send it free of user interaction, due to that messy script(or set of scripts) we have left to tackle.

Wednesday, June 17, 2015

Basic Audio Forensic Analysis Program

During a talent show at school I tried my hand at rapping and during a speed rap section the camera sampling rate blended words and an innocent and rather clever phrase was picked up as something entirely different(Yes I rapped).

Having another recording from an alternate source I set out to prove that there was a significant difference between the two recordings the reason however I would leave up to them, though in a coming post I think I'll make a digital forensics package(for files that is). Anywho lets get to it:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AudioAnalysis
{
    public partial class Form1 : Form
    {
        public Form1()
        {
           // reader2.Text = track0.Value.ToString();
                     InitializeComponent();
        }

        private void openWaveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            
            OpenFileDialog open = new OpenFileDialog();
            open.Filter = "Wave File (*.wav)|*.wav;";
            if (open.ShowDialog() != DialogResult.OK) return;

            waveViewer1.SamplesPerPixel = 450;
            waveViewer1.WaveStream = new NAudio.Wave.WaveFileReader(open.FileName);
            

            chart1.Series.Add("wave");
            chart1.Series["wave"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastLine;
            chart1.Series["wave"].ChartArea = "ChartArea1";

            NAudio.Wave.WaveChannel32 wave = new NAudio.Wave.WaveChannel32(new NAudio.Wave.WaveFileReader(open.FileName));

            byte[] buffer = new byte[track.Value];
            int read = 0;

            while (wave.Position < track.Value)
            {
                read = wave.Read(buffer, 0, track.Value);

                for (int i = track0.Value; i < read / 4; i++)
                {
                    chart1.Series["wave"].Points.Add(BitConverter.ToSingle(buffer, i * 4));
                    string stringy = (10*BitConverter.ToSingle(buffer, i * 4)).ToString();
                    outsalot.AppendText(stringy + "\n");
                    bar.Value = i;
                    if (bar.Value == bar.Maximum-1) { bar.Value = 0; }
                }
            }
        }

        private void readout_TextChanged(object sender, EventArgs e)
        {
            track.Value = Int32.Parse(readout.Text);
        }

        private void track_Scroll(object sender, EventArgs e)
        {
            readout.Text = track.Value.ToString();
            bar.Maximum = track.Value/4;
        }

        private void chart1_Click(object sender, EventArgs e)
        {

        }

        private void logToolStripMenuItem_Click(object sender, EventArgs e)
        {
            
        }

        private void track0_Scroll(object sender, EventArgs e)
        {

            reader2.Text = track0.Value.ToString();
           
        }

        private void reader2_TextChanged(object sender, EventArgs e)
        {
            track0.Value = Int32.Parse(reader2.Text);

            
        }

        private void hAMToolStripMenuItem_Click(object sender, EventArgs e)
        {

            for (int vxl = 0; vxl < outsalot.Lines.Length-5; vxl = vxl + 1)
            {
               string hamm = (float.Parse(outsalot.Lines[vxl]) - float.Parse(outsytwo.Lines[vxl])).ToString();
               hamming.Text = hamming.Text + hamm+"\n";
               bar.Maximum = outsalot.Lines.Length - 5;
               bar.Value = vxl;
               if (bar.Value == outsalot.Lines.Length - 10) { bar.Value = 0; }
        

            }
        
        }

        private void move_Click(object sender, EventArgs e)
        {
            outsytwo.Text = outsalot.Text;
                outsalot.ResetText();
                chart1.Series.Clear();
        }

        private void diracΔToolStripMenuItem_Click(object sender, EventArgs e)
        {
            
            for (int vxl = 0; vxl < outsalot.Lines.Length ; vxl = vxl + 1)
            {
                string hamm = ((float.Parse(outsalot.Lines[vxl]) - Int32.Parse(outsytwo.Lines[vxl]))/Math.Abs((float.Parse(outsalot.Lines[vxl]) - Int32.Parse(outsytwo.Lines[vxl])))).ToString();
             
                hamming.Text = hamming.Text + hamm + "\n";
                bar.Maximum = outsalot.Lines.Length;
                bar.Value = vxl;
                if (bar.Value == outsalot.Lines.Length - 10) { bar.Value = 0; }


            }
        }

        private void differenceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            for (int vxl = 0; vxl < outsalot.Lines.Length-1; vxl = vxl + 1)
            {
                string one = ((float.Parse(outsalot.Lines[vxl]) - float.Parse(outsalot.Lines[vxl+1]))) .ToString();
                

                hamming.Text = hamming.Text + one + "\n";
                bar.Maximum = outsalot.Lines.Length;
                bar.Value = vxl;
                if (bar.Value == outsalot.Lines.Length - 10) { bar.Value = 0; }


            }
            outsalot.Text=hamming.Text;
            hamming.Text="";
                        for (int vxl = 0; vxl < outsalot.Lines.Length-1; vxl = vxl + 1)
            {
                string two = ((float.Parse(outsytwo.Lines[vxl]) - float.Parse(outsytwo.Lines[vxl + 1]))).ToString();
                

                hamming.Text = hamming.Text + two+ "\n";
               
                bar.Maximum = outsytwo.Lines.Length;
                bar.Value = vxl;
                if (bar.Value == outsalot.Lines.Length - 10) { bar.Value = 0; }


            }
             outsytwo.Text=hamming.Text;
             hamming.Text = "";
        }

        private void hamming_TextChanged(object sender, EventArgs e)
        {
            hamming.Text = hamming.Text.Replace("NaN", "0");
        }
        }
        }

So the basic idea was to load the audio, split db and pitch into to sections(which is why I switched to the MS Studio C# collection as it has this lib function built in. Simple from here, we just break this down into text and output to two textboxes:

Sure, yeah, I could easily have used two strings to hold the data but the text box will come in handy later and it is useful for later running through the data and selecting rows. So we want to calculate the Hamming Distance so, made a File>HAM, option:

        private void hAMToolStripMenuItem_Click(object sender, EventArgs e)
        {

            for (int vxl = 0; vxl < outsalot.Lines.Length-5; vxl = vxl + 1)
            {
               string hamm = (float.Parse(outsalot.Lines[vxl]) - float.Parse(outsytwo.Lines[vxl])).ToString();
               hamming.Text = hamming.Text + hamm+"\n";
               bar.Maximum = outsalot.Lines.Length - 5;
               bar.Value = vxl;
               if (bar.Value == outsalot.Lines.Length - 10) { bar.Value = 0; }
        

            }
        
        }

which really just subtracts the two waveforms. How? well you need to open the two separate waveforms which is where the empty white textbox and the [Move] <button> come into play. Press the move button, open the second wave form and calculate the HAM.(Again File>HAM though hopefully you recall).

Also I should point out, I did not take the time to fix the scrolling bars at the top(these select how much of the WaveForm(.wav) files you wish to analyse. So what you need to do before even opening the first WAV is to move these around until numbers appear in the text box(I recommend 0 left and 16384 right, and just cut the audio so that they are in the same place on something like audacity). Now about what I just said about cutting them to the same place. You don't really need to. To check for changes that are not Amplitudinal(new word) then this is just a quick mathematical operation on the Hammed functions(not the difference of the WAV's). If the difference between each can be attributed to a multiplicative factor ie our strings are:

363693639
121231213

Then we can say that the only difference is caused by an audio gain function, whose multiplier is 3.

The DiracΔ function starts to hit on that:

        private void diracΔToolStripMenuItem_Click(object sender, EventArgs e)
        {
            
            for (int vxl = 0; vxl < outsalot.Lines.Length ; vxl = vxl + 1)
            {
                string hamm = ((float.Parse(outsalot.Lines[vxl]) - Int32.Parse(outsytwo.Lines[vxl]))/Math.Abs((float.Parse(outsalot.Lines[vxl]) - Int32.Parse(outsytwo.Lines[vxl])))).ToString();
             
                hamming.Text = hamming.Text + hamm + "\n";
                bar.Maximum = outsalot.Lines.Length;
                bar.Value = vxl;
                if (bar.Value == outsalot.Lines.Length - 10) { bar.Value = 0; }


            }
        }
It takes the vals, subtracts and divides by the absolute in order to work with multiplicatives. Does this have anything to do with DiracΔ functions. Not really I was just playing on the fact that the entire issue(dispute) is probably due to the lower sampling rate of the microphones used by the aggressors. 

Now the difference function( FILE>Difference), wait hold up, here is a pic of the menu for refs:
Right, and here is the code for Difference:

 private void differenceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            for (int vxl = 0; vxl < outsalot.Lines.Length-1; vxl = vxl + 1)
            {
                string one = ((float.Parse(outsalot.Lines[vxl]) - float.Parse(outsalot.Lines[vxl+1]))) .ToString();
                

                hamming.Text = hamming.Text + one + "\n";
                bar.Maximum = outsalot.Lines.Length;
                bar.Value = vxl;
                if (bar.Value == outsalot.Lines.Length - 10) { bar.Value = 0; }


            }
            outsalot.Text=hamming.Text;
            hamming.Text="";
                        for (int vxl = 0; vxl < outsalot.Lines.Length-1; vxl = vxl + 1)
            {
                string two = ((float.Parse(outsytwo.Lines[vxl]) - float.Parse(outsytwo.Lines[vxl + 1]))).ToString();
                

                hamming.Text = hamming.Text + two+ "\n";
               
                bar.Maximum = outsytwo.Lines.Length;
                bar.Value = vxl;
                if (bar.Value == outsalot.Lines.Length - 10) { bar.Value = 0; }


            }
             outsytwo.Text=hamming.Text;
             hamming.Text = "";
        }
Difference differs(ha) from the other functions in that it works or acts upon only one waveform(at a time and we could run Difference on the Hamming distance function of the two waveforms). It subtracts element [x] from element [x+1] all the way to [(max(x)-1)-(max(x)-2)], the reason being that the differences between successive elements should be the same in each waveform if they have not been tampered with and there is not too many confounding variables from outside sources(audience etc).

Now I ussually do not write up the code for the visuals but in this case it is useful as I did utilize a split container to hold everything. You can delete the db graph(top one) as it does nothing for us(volume is not entirely useful when we are talking about vocal modification, although we can sort of use it to mess with the difference functions we talked about earlier as I described them in terms of db and not pitch though they are currently programmed to work on pitch. To work on db you need to convert arrays to txt \n format).

namespace AudioAnalysis
{
    partial class Form1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
            this.menuStrip1 = new System.Windows.Forms.MenuStrip();
            this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.openWaveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.hAMToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.diracΔToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.differenceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.logToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.splitContainer1 = new System.Windows.Forms.SplitContainer();
            this.move = new System.Windows.Forms.Button();
            this.outsalot = new System.Windows.Forms.RichTextBox();
            this.waveViewer1 = new NAudio.Gui.WaveViewer();
            this.hamming = new System.Windows.Forms.RichTextBox();
            this.outsytwo = new System.Windows.Forms.RichTextBox();
            this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart();
            this.bindingSource1 = new System.Windows.Forms.BindingSource(this.components);
            this.track = new System.Windows.Forms.TrackBar();
            this.readout = new System.Windows.Forms.TextBox();
            this.bar = new System.Windows.Forms.ProgressBar();
            this.track0 = new System.Windows.Forms.TrackBar();
            this.reader2 = new System.Windows.Forms.TextBox();
            this.menuStrip1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
            this.splitContainer1.Panel1.SuspendLayout();
            this.splitContainer1.Panel2.SuspendLayout();
            this.splitContainer1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.track)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.track0)).BeginInit();
            this.SuspendLayout();
            // 
            // menuStrip1
            // 
            this.menuStrip1.BackColor = System.Drawing.Color.WhiteSmoke;
            this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.fileToolStripMenuItem,
            this.logToolStripMenuItem});
            this.menuStrip1.Location = new System.Drawing.Point(0, 0);
            this.menuStrip1.Name = "menuStrip1";
            this.menuStrip1.Size = new System.Drawing.Size(1091, 24);
            this.menuStrip1.TabIndex = 0;
            this.menuStrip1.Text = "menuStrip1";
            // 
            // fileToolStripMenuItem
            // 
            this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.openWaveToolStripMenuItem,
            this.hAMToolStripMenuItem,
            this.diracΔToolStripMenuItem,
            this.differenceToolStripMenuItem});
            this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
            this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
            this.fileToolStripMenuItem.Text = "File";
            // 
            // openWaveToolStripMenuItem
            // 
            this.openWaveToolStripMenuItem.Name = "openWaveToolStripMenuItem";
            this.openWaveToolStripMenuItem.Size = new System.Drawing.Size(135, 22);
            this.openWaveToolStripMenuItem.Text = "Open Wave";
            this.openWaveToolStripMenuItem.Click += new System.EventHandler(this.openWaveToolStripMenuItem_Click);
            // 
            // hAMToolStripMenuItem
            // 
            this.hAMToolStripMenuItem.Name = "hAMToolStripMenuItem";
            this.hAMToolStripMenuItem.Size = new System.Drawing.Size(135, 22);
            this.hAMToolStripMenuItem.Text = "HAM";
            this.hAMToolStripMenuItem.Click += new System.EventHandler(this.hAMToolStripMenuItem_Click);
            // 
            // diracΔToolStripMenuItem
            // 
            this.diracΔToolStripMenuItem.Name = "diracΔToolStripMenuItem";
            this.diracΔToolStripMenuItem.Size = new System.Drawing.Size(135, 22);
            this.diracΔToolStripMenuItem.Text = "DiracΔ";
            this.diracΔToolStripMenuItem.Click += new System.EventHandler(this.diracΔToolStripMenuItem_Click);
            // 
            // differenceToolStripMenuItem
            // 
            this.differenceToolStripMenuItem.Name = "differenceToolStripMenuItem";
            this.differenceToolStripMenuItem.Size = new System.Drawing.Size(135, 22);
            this.differenceToolStripMenuItem.Text = "Difference";
            this.differenceToolStripMenuItem.Click += new System.EventHandler(this.differenceToolStripMenuItem_Click);
            // 
            // logToolStripMenuItem
            // 
            this.logToolStripMenuItem.Name = "logToolStripMenuItem";
            this.logToolStripMenuItem.Size = new System.Drawing.Size(39, 20);
            this.logToolStripMenuItem.Text = "Log";
            this.logToolStripMenuItem.Click += new System.EventHandler(this.logToolStripMenuItem_Click);
            // 
            // splitContainer1
            // 
            this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.splitContainer1.Location = new System.Drawing.Point(0, 24);
            this.splitContainer1.Name = "splitContainer1";
            this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
            // 
            // splitContainer1.Panel1
            // 
            this.splitContainer1.Panel1.Controls.Add(this.move);
            this.splitContainer1.Panel1.Controls.Add(this.outsalot);
            this.splitContainer1.Panel1.Controls.Add(this.waveViewer1);
            // 
            // splitContainer1.Panel2
            // 
            this.splitContainer1.Panel2.Controls.Add(this.hamming);
            this.splitContainer1.Panel2.Controls.Add(this.outsytwo);
            this.splitContainer1.Panel2.Controls.Add(this.chart1);
            this.splitContainer1.Size = new System.Drawing.Size(1091, 461);
            this.splitContainer1.SplitterDistance = 227;
            this.splitContainer1.TabIndex = 1;
            // 
            // move
            // 
            this.move.Location = new System.Drawing.Point(926, 180);
            this.move.Name = "move";
            this.move.Size = new System.Drawing.Size(153, 23);
            this.move.TabIndex = 2;
            this.move.Text = "Move";
            this.move.UseVisualStyleBackColor = true;
            this.move.Click += new System.EventHandler(this.move_Click);
            // 
            // outsalot
            // 
            this.outsalot.Location = new System.Drawing.Point(926, 3);
            this.outsalot.Name = "outsalot";
            this.outsalot.Size = new System.Drawing.Size(153, 174);
            this.outsalot.TabIndex = 1;
            this.outsalot.Text = "";
            // 
            // waveViewer1
            // 
            this.waveViewer1.Location = new System.Drawing.Point(0, 6);
            this.waveViewer1.Name = "waveViewer1";
            this.waveViewer1.SamplesPerPixel = 128;
            this.waveViewer1.Size = new System.Drawing.Size(920, 195);
            this.waveViewer1.StartPosition = ((long)(0));
            this.waveViewer1.TabIndex = 0;
            this.waveViewer1.WaveStream = null;
            // 
            // hamming
            // 
            this.hamming.BackColor = System.Drawing.SystemColors.InactiveCaptionText;
            this.hamming.ForeColor = System.Drawing.SystemColors.Menu;
            this.hamming.Location = new System.Drawing.Point(788, 4);
            this.hamming.Name = "hamming";
            this.hamming.Size = new System.Drawing.Size(132, 213);
            this.hamming.TabIndex = 2;
            this.hamming.Text = "";
            this.hamming.TextChanged += new System.EventHandler(this.hamming_TextChanged);
            // 
            // outsytwo
            // 
            this.outsytwo.Location = new System.Drawing.Point(926, 4);
            this.outsytwo.Name = "outsytwo";
            this.outsytwo.Size = new System.Drawing.Size(162, 213);
            this.outsytwo.TabIndex = 1;
            this.outsytwo.Text = "";
            // 
            // chart1
            // 
            chartArea1.Name = "ChartArea1";
            this.chart1.ChartAreas.Add(chartArea1);
            this.chart1.Location = new System.Drawing.Point(0, 0);
            this.chart1.Name = "chart1";
            this.chart1.Palette = System.Windows.Forms.DataVisualization.Charting.ChartColorPalette.EarthTones;
            this.chart1.Size = new System.Drawing.Size(782, 201);
            this.chart1.TabIndex = 0;
            this.chart1.Text = "chart1";
            this.chart1.Click += new System.EventHandler(this.chart1_Click);
            // 
            // track
            // 
            this.track.Location = new System.Drawing.Point(519, 0);
            this.track.Maximum = 16384;
            this.track.Name = "track";
            this.track.Size = new System.Drawing.Size(303, 45);
            this.track.TabIndex = 1;
            this.track.Value = 16384;
            this.track.Scroll += new System.EventHandler(this.track_Scroll);
            // 
            // readout
            // 
            this.readout.BackColor = System.Drawing.SystemColors.HotTrack;
            this.readout.ForeColor = System.Drawing.SystemColors.Menu;
            this.readout.Location = new System.Drawing.Point(464, 4);
            this.readout.Name = "readout";
            this.readout.Size = new System.Drawing.Size(49, 20);
            this.readout.TabIndex = 2;
            this.readout.TextChanged += new System.EventHandler(this.readout_TextChanged);
            // 
            // bar
            // 
            this.bar.Location = new System.Drawing.Point(816, 0);
            this.bar.Name = "bar";
            this.bar.Size = new System.Drawing.Size(272, 23);
            this.bar.TabIndex = 3;
            // 
            // track0
            // 
            this.track0.BackColor = System.Drawing.SystemColors.Control;
            this.track0.Location = new System.Drawing.Point(82, -2);
            this.track0.Maximum = 16384;
            this.track0.Name = "track0";
            this.track0.Size = new System.Drawing.Size(303, 45);
            this.track0.TabIndex = 4;
            this.track0.Scroll += new System.EventHandler(this.track0_Scroll);
            // 
            // reader2
            // 
            this.reader2.BackColor = System.Drawing.Color.Maroon;
            this.reader2.ForeColor = System.Drawing.SystemColors.Menu;
            this.reader2.Location = new System.Drawing.Point(388, 4);
            this.reader2.Name = "reader2";
            this.reader2.Size = new System.Drawing.Size(49, 20);
            this.reader2.TabIndex = 5;
            this.reader2.TextChanged += new System.EventHandler(this.reader2_TextChanged);
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(1091, 485);
            this.Controls.Add(this.reader2);
            this.Controls.Add(this.track0);
            this.Controls.Add(this.bar);
            this.Controls.Add(this.readout);
            this.Controls.Add(this.track);
            this.Controls.Add(this.splitContainer1);
            this.Controls.Add(this.menuStrip1);
            this.MainMenuStrip = this.menuStrip1;
            this.Name = "Form1";
            this.Text = "AudioAnalysis";
            this.menuStrip1.ResumeLayout(false);
            this.menuStrip1.PerformLayout();
            this.splitContainer1.Panel1.ResumeLayout(false);
            this.splitContainer1.Panel2.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
            this.splitContainer1.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.track)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.track0)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.MenuStrip menuStrip1;
        private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem openWaveToolStripMenuItem;
        private System.Windows.Forms.SplitContainer splitContainer1;
        private NAudio.Gui.WaveViewer waveViewer1;
        private System.Windows.Forms.DataVisualization.Charting.Chart chart1;
        private System.Windows.Forms.ToolStripMenuItem logToolStripMenuItem;
        private System.Windows.Forms.BindingSource bindingSource1;
        private System.Windows.Forms.TrackBar track;
        private System.Windows.Forms.TextBox readout;
        private System.Windows.Forms.RichTextBox outsalot;
        private System.Windows.Forms.ProgressBar bar;
        private System.Windows.Forms.RichTextBox outsytwo;
        private System.Windows.Forms.TrackBar track0;
        private System.Windows.Forms.TextBox reader2;
        private System.Windows.Forms.ToolStripMenuItem hAMToolStripMenuItem;
        private System.Windows.Forms.RichTextBox hamming;
        private System.Windows.Forms.Button move;
        private System.Windows.Forms.ToolStripMenuItem diracΔToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem differenceToolStripMenuItem;
    }
}

Saturday, August 30, 2014

VD New Features

Also added some new features to VD and Open Bio. Vd now has an FTP through Google Drive
as well as a redesigned GUI:
and a Neumman System(Code which edits itself) and a Fluid Type system which are coming out in the next update. Also the OCTR(Open Cosmic Ray Telescope) will have it's own blog post soon, unforturnately some of the supplies are taking  a while. When that is released there will be full schematics and open software which I shall place in the XOS Industries Software Repo.

Tuesday, May 6, 2014

Distance and location using internet message time differentials for use in source tracking

Overview:
Messages sent over the internet take time to get to the sender, typically. D/C<D/S because the messages travel through routing stations and are not entirely photonic. Obviously these messages display where they came from for things such as email( but this is relative, an email from Russia may say from Moscow despite coming from Novosibirsk. However we can use Δt of the sent time stamp and the receive time stamp to create a circle around our location and the sender's location is on the circumference, then by searching for major population centers and or using routing information from the routing servers, the algorithms can determine the senders location very accurately:
PHP Server Side:
1. Let's get the current time for the observer:
Wow a monstrous four lines(sarcasm)
2. Now the time that the sender saw the file leave(by time line I mean the line containing the time):








3.Now let's subtract the times; we need to sift out all letters from the alphanumeric known as $stringcheese, so that we can get just the time:
This works because our timestamp will be 'time $militarytime'. Using military time eliminates the problem of searching the string for AM or PM.
/////////////////////////////////////////////////////
Determining Average Speed of the Signal:
Using a Mac just to mash things up a bit. We need the time it takes for the signal  to leave our computer and return from a location.The  methodology is the same as in the North Korea Server post but this time I will use a Mac, however the commands are the same:

User$ ping www.facebook.com
PING star.c10r.facebook.com (31.13.71.33): 56 data bytes
64 bytes from 31.13.71.33: icmp_seq=0 ttl=87 time=39.729 ms
64 bytes from 31.13.71.33: icmp_seq=1 ttl=87 time=39.523 ms
64 bytes from 31.13.71.33: icmp_seq=2 ttl=87 time=39.123 ms
64 bytes from 31.13.71.33: icmp_seq=3 ttl=87 time=38.707 ms
64 bytes from 31.13.71.33: icmp_seq=4 ttl=87 time=36.871 ms
64 bytes from 31.13.71.33: icmp_seq=5 ttl=87 time=39.909 ms
64 bytes from 31.13.71.33: icmp_seq=6 ttl=87 time=37.632 ms
64 bytes from 31.13.71.33: icmp_seq=7 ttl=87 time=40.425 ms
64 bytes from 31.13.71.33: icmp_seq=8 ttl=87 time=39.038 ms
64 bytes from 31.13.71.33: icmp_seq=9 ttl=87 time=41.607 ms

Speed:
We can easily find where 31.13.71.33 is with a web search:
The distance there is about:
4748 km and the average time is about 40 s, but the signals travel double the distance so d==9496km and d/x=40 therefore x==237.4km/sec. Thus -237.4*$dt==radius.Note the negative because we used observer time minus received time and for most applications the observer has to send a message before the receiver can receive it. Now for the city search algorithm.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Code Outline:
First we will use a Google maps api to easily display our location graphically and numerically through HTML
It is of the utmost importance that the degree of magnification or the distance from the earth's surface is a constant so, I will rewrite the HTML file to include this necessity at the end. Finally we will display a circle of radius r, save the radius as r.txt, and open an image of our file in java/processing so that the computer can calculate the most probable point of origin. The logical way to do this is to view the world by night and use light pollution as the indicator for the presence of human life. The more life, the more light and vice versa. However the API does not use this map, so we will search for the presence of a specific color, a grey~tan which is associated with the concrete of urban areas:



And the Grey is:

HTML:
Now for the HTML/Javascript code to find us and display us on a map:

<!DOCTYPE html>
<html>
  <head>
    <title>Location Location Location</title>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
    <style>
      html, body, #map-canvas {
        height: 100%;
        margin: 0px;
        padding: 0px
      }
    </style>

    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=true"></script>

    <script>

var map;

function initialize() {
  var mapOptions = {
    zoom: 10
  };
  map = new google.maps.Map(document.getElementById('map-canvas'),
      mapOptions);

  // attempts HTML GEOLOCATE(MUST BE HTML 5)
  if(navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
      var pos = new google.maps.LatLng(position.coords.latitude,
                                       position.coords.longitude);
      alert(pos); //this displays our location
                                                       

      var infowindow = new google.maps.InfoWindow({
        map: map,
        position: pos,
        content: 'Found You'
      });

      map.setCenter(pos);
    }, function() {
      handleNoGeolocation(true);
    });
  } else {
    // Browser doesn't support Geolocation
    handleNoGeolocation(false);
  }
}

function handleNoGeolocation(errorFlag) {
  if (errorFlag) {
    var content = 'Error: The Geolocation service failed.';
  } else {
    var content = 'Error: Your browser doesn\'t support geolocation.';
  }

  var options = {
    map: map,
    position: new google.maps.LatLng(60, 105),
    content: content
  };

  var infowindow = new google.maps.InfoWindow(options);
  map.setCenter(options.position);
}

google.maps.event.addDomListener(window, 'load', initialize);

    </script>
  </head>
  <body>
    <div id="map-canvas"></div>
  </body>

</html>
Screenshot:
Awesome! Now we need to write a program to capture an image of our area and search for major population centers within the radius, which is defined in the preceding PHP scripts.

In Linux:
$ gnome-screenshot -w -B
This will Screenshot our HTML window. In order to do this we should get rid of the alert() function in the javascript so the HTML tracker reads:
<!DOCTYPE html>
<html>
  <head>
    <title>Location Location Location</title>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
    <style>
      html, body, #map-canvas {
        height: 100%;
        margin: 0px;
        padding: 0px
      }
    </style>

    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=true"></script>

    <script>

var map;

function initialize() {
  var mapOptions = {
    zoom: 10
  };
  map = new google.maps.Map(document.getElementById('map-canvas'),
      mapOptions);

  // attempts HTML GEOLOCATE(MUST BE HTML 5)
  if(navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
      var pos = new google.maps.LatLng(position.coords.latitude,
                                       position.coords.longitude);
    
                                                       

      var infowindow = new google.maps.InfoWindow({
        map: map,
        position: pos,
        content: 'Found You'
      });

      map.setCenter(pos);
    }, function() {
      handleNoGeolocation(true);
    });
  } else {
    // Browser doesn't support Geolocation
    handleNoGeolocation(false);
  }
}

function handleNoGeolocation(errorFlag) {
  if (errorFlag) {
    var content = 'Error: The Geolocation service failed.';
  } else {
    var content = 'Error: Your browser doesn\'t support geolocation.';
  }

  var options = {
    map: map,
    position: new google.maps.LatLng(60, 105),
    content: content
  };

  var infowindow = new google.maps.InfoWindow(options);
  map.setCenter(options.position);
}

google.maps.event.addDomListener(window, 'load', initialize);

    </script>
  </head>
  <body>
    <div id="map-canvas"></div>
  </body>

</html>

By eliminating the alert(pos); line the command script can now be used to Start firefox and open the HTML file, and then screenshot it.
$ do firefox 'SourcePath of the HTML FILE',sleep(10),gnome-screenshot -w -B
Great!  Now you can set up the above line to save it to the location of you're choice.

Groovy. Now time for Processing/Java.
Java/Processing:












N=The number of sides of the polygon and R is the radius of the circumscribed circle which is equal to the radius of the php script, and A=-1.

This is a fair region for the computer to search, but it should be rather quick.

The Processing Side of things will be done with a similar method to that of my post on my novel Morley Pintururia Naturaleza Muerta Smoothing Algorithm post. In terms of the area to cover, if we were to add in a script which modified the circle to be a regular polygon to try to reduce some of the searching, then:


PImage img;
int a, b,r,u;

void setup() {
  size(1000, 900);
  img = loadImage("cat.jpg");
  a = 1;
  b = 1;
  r=img.width;
  u=0;
  imageMode(CENTER);
  noStroke();
  background(0);

}

void draw() { 

  float pixel = map(11, 0, width, a, b);
  int x = int((img.width)-r);
  int y = int(random(img.height));
  color pix = img.get(x, y);
  fill(pix, 128);
  rect(x-1, y, pixel, pixel);
  rect(x+1, y, pixel, pixel);
  rect(x, y-1, pixel, pixel);
  rect(x, y+1, pixel, pixel); 
   println(pix);
  if pix=(//this will be our city color){
  println("we have a city here");
}
if(r==500){
  r=img.width;
}
}

The above code will find cities but does not compare them in terms of size, in order to achieve this we write the following:
PImage img;
int a, b,r,u;

void setup() {
  size(1000, 900);
  img = loadImage("cat.jpg");
  a = 1;
  b = 1;
  r=img.width;
  u=0;
  imageMode(CENTER);
  noStroke();
  background(0);

}

void draw() { 

  float pixel = map(11, 0, width, a, b);
  int x = int((img.width)-r);
  int y = int(random(img.height));
  color pix = img.get(x, y);
  fill(pix, 128);
  rect(x-1, y, pixel, pixel);
  rect(x+1, y, pixel, pixel);
  rect(x, y-1, pixel, pixel);
  rect(x, y+1, pixel, pixel); 
   println(pix);
  if (pix=(//this will be our city color))
  println("1");
else{
println("0");
}
if(r==500){
  r=img.width;
}
}
Now we have an array map of where the sender is!