Analyse SWF-Files with Java - java

I stumbled upon the need to find out (inside Java code) which files are dynamically loaded by an SWF-file. Is there any possibility to get a list of paths of every object referenced inside?
I tried out some libraries without proper documentation and gave up. Although I ran out of Google Search Phrases... ;)
Maybe there is an external tool which can be accessed by Java via command line?
Ggreat thanks in advance

Maybe you can get to the information you need using the dump tool which is part of Apparat.
I use actionscript more than Java, so I also recommend having a look at AS3SWF which is a great library you could use to load and analyze the swf you need. Think of it as decompiling at runtime.
Either way, the SWF Format Specifications will come in handy.
I'm not sure there's something that does exactly what you want, but I imagine you could collect all the strings (DefineText tags), loop through them and run an URL RegEx against them.

I think even if you could analyze a SWF file, you can't be sure to get this information. I have Flex Project (finally a swf file) which dynamically loads some modules, but the names (URLs) of the available modules are requested from the server. So there is no chance to retrieve this information from the main swf file.

Related

Is there any way I can try to read files with suffix like '.sas7bdat', '.dta', '.sav' and '.xpt' by using JAVA?

I am working on a module, which can import different kinds of files(currently those file types are SAS output format). Of course, this module is written by java, springboot. The main logic is that when user upload a file, the controller will pass the file inputstream to this module, and call the corresponding method by the file's suffix.
I have done some investigation and found that R-language and python could do this. Can anybody tell me whether there is another way, I mean, can do this job only by JAVA. Thanks.
The sas7bdat is a binary, proprietary format. Its layout has never been made public. Some people have figured it out (like the parso mentioned in the comment). If you really want to go down this path, use the python library as a guide. It will help with sas7bdat and sas7bcat. For the old SAS transport format, see my library on GitHub which is in C#. The new transport format appears to have some incorrect information in its description on the SAS website which I couldn't get around. I have put my code on GitHub in case you want to try.
All that said, let me offer a few words of wisdom: don't do it. Use the python library vs doing it in Java. Also, these libraries read the format vs having read/write. Keep that in mind (it sounds like it doesn't matter but FYI).

C++ or Java Library for automated code editing?

I am writing/planning to write a program that takes in a java file (or multiple java files), and edits and adds functions/classes/variables and then outputs a new java file (or multiple files).
Is there a C++ or Java library that
Can recognize and output names of classes/functions within a text file
Can recognize and output the names of the input arguments for said classes/functions
Can allow me to insert code at specific lines or within specific functions
Can search for a given variable name/value
Maintains original file formatting
I would prefer not having to manually code something to do the above, so any help would be appreciated.
Thank you in advance!
EDIT: I currently use Eclipse, and am unsure of how to proceed. So to further explain my question:
In eclipse, if I write a program that opens another .java file, How would I go about 'asking' eclipse to output, say, all the class names of the .java file I just opened?
Also I will explain the 'purpose' of this project to further clarify. I want to write a program that can take in any java file, and turn it into a class that can implemented remotely via RMI. To do this I will need to add an execute() function, have the file implement Task and Serializable and add a few variables, etc... Based on my knowledge, doing this in Eclipse would require manual editing of the program, but I would like to completely automate this process.
Thank you, again.
Much of what you need can be found in a modern IDE; and some very good IDEs are open source (eclipse and Intellij IDEA Community Edition for Java). You might look there to see if there are modules that suite your needs.
Looks like you are talking of a tool like eclipse. You might not be looking for a full fledged IDE, but the requirements that you have mentioned are fulfilled by any basic IDE.
If you wish to make one of your own, you can do that using eclipse rich client platform.
All that you would need from Java is the reflection API.

Accessing directories in Unix using Java

I tried Googling but was unable to come up with any results. What I'm looking for is a basic explanation or tutorial on howto navigate a Unix server with Java.
I have several Java programs that I would like to run directly on my server, however I just have no idea how to let these programs go to certain directories, or scan certain files, etc.
How exactly can I use Java with Unix?
Use File. Specify a path, see if it is a directory, open it, read it, delete it, etc, etc, etc.
listFile will give the files within a directory.
To make your life easier use Apache commons-io FileUtils -> http://commons.apache.org/io/api-release/org/apache/commons/io/FileUtils.html
Here is the project home page -> http://commons.apache.org/io/
Here you can find simplest guides:
http://docs.oracle.com/javase/tutorial/essential/io/
http://www.tutorialspoint.com/java/java_files_io.htm
http://home.cogeco.ca/~ve3ll/jatutor9.htm

How to make a program that automatically synchronizes

Hey i am hoping to write a program where the program automatically just copy pastes all my dad's documents from D:\office folder. So whenever I plug-in my pen-drive , the program silently copies all documents inside my pen-drive. Also all files should be pasted to a hidden folder in the pen-drive (so it remains private) . Synchronization capability also required ...So which language should be easy and where to get started ...any idea ??.
Seems to me that some spyin' is about to be goin' on here. :P
I'd recommend C++. Not extremely easy as .Net's tillyvally but fast, framework independent, convenient to manipulate Windows API. You wanna do advanced stealth app, you can't pick the easy way.
Why use the clipboard when you could just use shell commands???
Maybe write an autostart batch file on your pen drive that copies files to/from your flash drive as needed.
I infer you are on Windows. Window has a plethora of functions to manipulate files. A few functions are below.
CopyFile Copies an existing file to a new file.
FindFirstFile Searches a directory for a file or subdirectory name that matches a specified name.
FindFirstFileEx Searches a directory for a file or subdirectory name and attributes that match those that are specified.
FindNextFile Continues a file search.
MoveFile Moves an existing file or directory and its children.
On and on. These and many more functions are documented here.
File Management Functions
Copy or move the files to the pen drive.
HTH
I hate to be the person who suggests this (I don't like .NET that much):
Make a C# (or VB if you must) Console app, or Forms app (if you want to get fancy). The .NET framework will make this kind of program VERY easy and it might be fun. Unless you want to increase your proficiency in C/C++, i would suggest NOT doing it in those languages since there is a learning curve and it is a little complex to do some simple things.
"Just paste" or "synchronize"?
For synchronization, unison is a good bet, see http://en.wikipedia.org/wiki/Unison_(file_synchronizer). For "just paste", you could code a call to a batch calling XCOPY from with the Windows Autoplay mechanism.
Sounds like a secret covert operation you're talking about, though...
I think that you will need to do a lot of work to get a less than satisfactory result.
I would suggestion you instead have a look at DropBox, which is free up to 2Gb of storage which automatically synchronizes between all registered computers, plus has a special folder which allows for web access. Very nice.
I would suggest to use Camel framework of Java, there you can easily run service which will for example automatically copy data from your flash disk after plug in, to folder which you specify etc.
Good tutorial how to start is here:
https://www.youtube.com/watch?v=dmtXkA7FlwA

How to make graph from perf4j log file?

I have used perf4j to calculate the performance of the process. Now I want to make the graph for that file. Is it possible to make it without using Google API or any other method that can be used?
You have a couple of options:
When you use the org.perf4j.LogParser to parse your log, you can use the "--format csv" option to generate CSV output, open this up in Excel, then create a graph in Excel.
As the other poster said, I'm not sure why you're against using the Google Chart API, but if you are dead set against using it, note that the JFreeChart guys provide an implementation of the Google Chart APIs called Eastwood Charts: http://www.jfree.org/eastwood/. You could just set up an eastwood server and then proxy (or just set up in a hosts file) chart.apis.google . com to your eastwood server. Alternatively, if you look at the org.perf4j.LogParser class, you can override the newMeanTimeChartGenerator and newTpsChartGenerator methods to call the GoogleChartGenerator constructor that takes the base URL.
You can always create another implementation of the StatisticsChartGenerator interface and use this instead. Obviously this is the most involved option.
Can you explain a bit more as to why you want to avoid Google Charting APIs (I ask since I am intrigued as to why someone would not want to do something that is very simple, elegant and FREE)?
Also there is a GraphingServlet section "Exposing Performance Graphs in a Web Application" which I think internally does the same thing.
If you still want you can take the graph data (in raw csv format) and write some helper classes to create charts using libraries like jfreechart (rich client)
follow the following steps;
Go to the location where your perf4j log file exits and open command prompt there.
Hit the following command in cmd, make sure you have java(jdk) path set as environment variable and perf4j jar on this location:
java -jar perf4j-0.9.16.jar --graph perfGraphs.html perfLogFile.log
this will generate perfGraphs.html file in this location, which consists of graphs.

Categories

Resources