Changing A JavaCard's ATR - python

I am researching uses for Javacards and smartcards utilizing
different ATRs. I want to change these card's ATRs via python to be
different from the OEM ATR that comes on these cards as default. I
figured out a way to change the card's atr, however, it is utilizing a
script online - which really doesn't help.
Below is the script I found to change the ATR using PyResMan
script mode, however, it is only set to one atr, which is a bank and I
have no use for it.
The Script I found Online: {
(Beginning numbers show line numbers)
00A4040010********************************
00F00000
C0D6029A02F807
C0D601240108
C0D601470108
C0D601260403600000
C0D601490403600000
C0D6012201FE
C0D601360E0D80318065B0893501F183009000
C0D601590E0D80318065B0893501F183009000
C0D603010101
C0D6030510404142434445464748494A4B4C4D4E4F
C0D6031d0101
C0D6032110404142434445464748494A4B4C4D4E4F
C0D603390101
C0D6033D10404142434445464748494A4B4C4D4E4F
}
The problem with this script is that I only know what the first 2
lines do, and that lines 9&10 are the lines that actually contain the
data for the ATR changing process. I need to know how I can change the
ATR using the ATR in regular expression form.
If anyone knows a way to decode this script, and be able to edit it,
or knows an easier way to change the ATR of an Unfused or non
pre-presonialized javacard, please let me know! I've been researching
those for over a month now, and cannot find an answer that actually
works.

Setting the ATR for a smartcard is not primarily the domain of Javacard specification. Today there is no generic specification or method to set the ATR for all smartcards, as there is no universal way to initialize or personalize the smartcard itself and this is mostly vendor specific.
The script that you found online belongs to an NXP Javacard, this information is not standardized and is also not intended for public use to my knowledge, therefore is removed some sensible information. Please contact your card vendor to get information on how to change the ATR(it might not be possible or easy).

Related

Python, remove password from memory

Im storing some user raw_input as a variable in Python 2.7, the issue is that this is sensitive as it is the encryption passphrase for a cryptocurrency wallet.
Therefore I want to ensure that once the Python script is completed, there is no trace of the passphase left anywhere on the system.
Where passphrase is the variable, is this at the end of the program:
del passphrase
good to utterly remove all traces?
No del xxx or implicit deletion (leaving the current scope) may not be enough to hide the previously stored value. Note that this may crucially depend on your OS and your Python implementation.
However I would advise not to roll your own security systems unless you really, really know what you're doing but rather search an already existing solution for whatever it is you want to do and use that. For example I'm not sure if either raw_input or input are suitable for cryptographical needs.
You may get additional help in Information Security StackExchange.

Under spf13-vim, how to jump to next item in the loop

I am new to spf13-vim configuration. I have a basic problem; for example, when I am writing a python script, if I type "for" in vim console, I could see:
1 for item in <`2:items`>:
2 <`0`>
Then I can type any variable on "item", but I couldn't figure out how to jump to the next item, "<2:items>". How could I do that?
The direct answer to your question is: press Tab.
This feature is most certainly not provided by spf13 itself: it is provided by a snippet-expansion plugin that comes with spf13. Maybe it's SnipMate? Maybe it's UltiSnips? Maybe another one? Who even knows? You could simply look up up the documentation of that plugin but you can't, because you don't know what plugins you have.
Well, you are supposed to know what the plugins you add to your config that you manage yourself do and do not. But you don't, because you gave away that responsibility to someone else and you end up with a black box that contains and does things you have no idea about.
And the best part is that you don't even ask for help to the author/maintainer of that crappy distribution. They lured you into installing their stuff and giving control up, they are the ones who should help their poor, misled, users.
If you are serious about using Vim, drop spf13 immediately and take care of your configuration yourself.
If you don't care about doing things the right way, use another editor.
Press Ctrl+k to jump to the next item.

How do you properly modify packet data in Scapy?

I’ve been using Scapy a bit and have been messing around with making packets. A problem I have is trying to specify certain data/options in packets. For example, I want to make a DHCP packet with option 60 but I don’t know what is valid input data to use for this. I know the packet should have a DHCP.options list and I can add options like this into the list, but how do I know what type and what range of data I can actually use? I also know I can type DHCPOptions at the interpreter to see that it’s a ‘vendor class id’, but how would I actually properly add it to a packet?
Another example: for a TCP timestamp option, I discovered that I have to enter that as (‘Timestamp’, (int,int)), in other words a tuple of the string Timestamp and a tuple within that tuple of two integers, within some sort of range I don’t know.
So ultimately, my question is where/how do I find out how to add valid input data into packets in Scapy? Is there a list or documentation somewhere? I’ve searched around but couldn’t find it even in the source code and the documentation doesn’t seem helpful at all. Help is greatly appreciated!
Sample code:
p = Ether()/IP()/UDP()/BOOTP()/DHCP()
# ?:what goes in the list to correctly add any option?
p[DHCP].options = [(?,?)]
# Trying to add option 60 here, unsure how
p[DHCP].options.append( ('vendor_class_id', ?) )
I use option 60 merely as an example, but I want to know how to add any valid option.
well, this might not be the full answer, since i also found it hard to find such info, but...
for some options, you can check in dhcp.py how they are defined in DHCPOptions dictionary - for example, you see that renewal_time by its definition is of int type and as default set to 21600 - IntField("renewal_time", 21600).
for other info, i suggest to dig through RFCs. for example, RFC 2132 describes DHCP Options and BOOTP Vendor Extensions.
RFC 1497 solely refers to Vendor options.

Updating files with a Perforce trigger before submit

I understand that this question has, in essence, already been asked, but that question did not have an unequivocal answer, so please bear with me.
Background: In my company, we use Perforce submission numbers as part of our versioning. Regardless of whether this is a correct method or not, that is how things are. Currently, many developers do separate submissions for code and documentation: first the code and then the documentation to update the client-facing docs with what the new version numbers should be. I would like to streamline this process.
My thoughts are as follows: create a Perforce trigger (which runs on the server side) which scans the submitted documentation files (such as .txt) for a unique term (such as #####PERFORCE##CHANGELIST##NUMBER###ROFL###LOL###WHATEVER#####) and then replaces it with the value of what the change list would be when submitted. I already know how to determine this value. What I cannot figure out, is how or where to update the files.
I have already determined that using the change-content trigger (whether possible or not), which
"fire[s] after changelist creation and file transfer, but prior to committing the submit to the database",
is the way to go. At this point the files need to exist somewhere on the server. How do I determine the (temporary?) location of these files from within, say, a Python script so that I can update or sed to replace the placeholder value with the intended value? The online documentation for Perforce which I have found so far have not been very explicit on whether this is possible or how the mechanics of a submission at this stage would work.
EDIT
Basically what I am looking for is RCS-like functionality, but without the unsightly special character sequences which accompany it. After more digging, what I am asking is the same as this question. However I believe that this must be possible, because the trigger is running on the server side and the files had already been transferred to the server. They must therefore be accessible by the script.
EXAMPLE
Consider the following snippet from a release notes document:
[#####PERFORCE##CHANGELIST##NUMBER###ROFL###LOL###WHATEVER#####] Added a cool new feature. Early retirement is in sight.
[52702] Fixed a really annoying bug. Many lives saved.
[52686] Fixed an annoying bug.
This is what the user submits. I then want the trigger to intercept this file during the submission process (as mentioned, at the change-content stage) and alter it so that what is eventually stored within Perforce looks like this:
[52738] Added a cool new feature. Early retirement is in sight.
[52702] Fixed a really annoying bug. Many lives saved.
[52686] Fixed an annoying bug.
Where 52738 is the final change list number of what the user submitted. (As mentioned, I can already determine this number, so please do dwell on this point.) I.e., what the user sees on the Perforce client console is.
Changelist 52733 renamed 52738.
Submitted change 52738.
Are you trying to replace the content of pending changelist files that were edited on a different client workspace (and different user)?
What type of information are you trying to replace in the documentation files? For example,
is it a date, username like with RCS keyword expansion? http://www.perforce.com/perforce/doc.current/manuals/p4guide/appendix.filetypes.html#DB5-18921
I want to get better clarification on what you are trying to accomplish in case there is another way to do what you want.
Depending on what you are trying to do, you may want to consider shelving ( http://www.perforce.com/perforce/doc.current/manuals/p4guide/chapter.files.html#d0e5537 )
Also, there is an existing Perforce enhancement request I can add your information to,
regarding client side triggers to modify files on the client side prior to submit. If it becomes implemented, you will be notified by email.
99w,
I have also added you to an existing enhancement request for Customizable RCS keywords, along
with the example you provided.
Short of using a post-command trigger to edit the archive content directly and then update the checksum in the database, there is currently not a way to update the file content with the custom-edited final changelist number.
One of the things I learned very early on in programming was to keep out of interrupt level as much as possible, and especially don't do stuff in interrupt that requires resources that can hang the system. I totally get that you want to resolve the internal labeling in sequence, but a better way to do it may be to just set up the edit during the trigger so that a post trigger tool can perform the file modification.
Correct me if I'm looking at this wrong, but there seems a bit of irony, or perhaps recursion, if you are trying to make a file change during the course of submitting a file change. It might be better to have a second change list that is reserved for the log. You always know where that file is, in your local file space. That said, ktext files and $ fields may be able to help.

Programatically set IE Zoom level in Selenium Python

I am getting the zoom level error for IE which I understand is a known issue. I've been able to find a resolution for this in both Java and C# but I can't seem to find the workaround in Python. Here is what has been reported to work in Java and C#:
System.setProperty("webdriver.ie.driver", IEDriverLocation);
DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
caps.setCapability("ignoreZoomSetting", true);
aDriver = new InternetExplorerDriver(caps);
Anyone have any experience doing the same thing in Python? I'd also be fine with a set zoom level to 100% but I have not been successful with any iteration of that phrase in python.
You can edit the registry to ensure that the zoom level for IE is set to 100% before launching your test.
The registry setting is at HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Zoom
For 100% zoom, you'll want the value for the ZoomFactor to be 100000 or 186a0 (if you need the hexidecimal value).
Since you're using Python, it looks like you could use the winreg module to edit the Windows registry.
If you are like me, every time you searched for a python specific way to ignore Zoom you found your way here. For anyone else out there who keeps running into this post on Google- you need to pass "ignoreZoomSetting" in as a dictionary when creating a web driver instance. By default, ignoreZoomSetting is set to False:
page = webdriver.Ie(executable_path="C:\\IEDriverServer.exe", capabilities={'ignoreZoomSetting':True})
page.get('https://www.google.com/')
Keep in mind the zoom setting is required for native mouse events, as referenced here. You will probably run into some odd situations as I did.

Categories