• Post Reply Bookmark Topic Watch Topic
  • New Topic

modifying class files  RSS feed

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, I am reading a class file (as a RandomAccessFile) in byte format and am modifying a part of the class file by increasing the length of one of the attributes. As a consequence, I am getting a class format error.
Can anyone tell me a way of modifying a class file via another Java program?For example : Program A when run says"Hello Johnny". I want program B to modify A to say Hello Sally" when program A is run again
 
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at Jakarta's BCEL.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John,
Forgive my ignorance here; however, wouldn't it be a better idea to externalize those parameters which may change based upon the business needs. Accordingly, other attributes which may change from customer to customer should be in a database somewhere. I wonder how you will debug this type of code, or how the next person will after you move on.
Jerome
 
John Pa
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jerome, Yes your observation is correct if the application was business related.But my focus is on evaluating the security of mobile code.I am working with Java Agents and by modifying class files, I intend to illustrate, one of the ways of hacking /mofifying an agent's functionality through another agent.Once this is done, the solution I am proposing will fit in. Currently, I seem to have the solution but only a theoretical vision of the problem.To illustrate the problem in a practical sense, I need to give an example and hence this question. Cheers, John
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!