How do I safely extend electrical wiring without replacing it entirely?
You are sunk

Wire that short can't be spliced or extended. The wire must be able to come out beyond the surface of the box at least 3". 

You will need to reroute these cables to a different junction box somewhere the wiring is able reach with the needed spare length inside the box.  From there, you can run a /2 w/ground cable to this location, e.g. NM or MC.  

The junction box where this happens must have its cover remain accessible  without needing tools to disassemble any part of the building. The attic is fine.