Friday, January 8, 2016

I am trying to teach myself to program using the interactivepython.org website. I have run into a problem that seems to be way over my head. I've been working on it for 3 hours straight and am racking my noggin. Not sure how to break this down at all.
Problem:
Decoding a secret message:
The description may seem daunting, but the solution is not that hard. You can use the built-in string datatype with the associated built-in functions and while loop (with ‘len’ function) or a for loop (with ‘in’ operator) to traverse the string. Also, use the ’chr’ and ’ord’ functions (which are based on ASCII code) discussed in course material. Make sure to look at the examples in the course material and do #18 and #19 in Exercises 2. Answer for #19 is provided and it can give valuable hints for solving this problem.

Your country is at war and your enemies are using a secret code to communicate with each other. You have managed to intercept a message that read as follows:
:mmZ\dxZmx]Zpgy
The message is obviously encrypted using the enemy’s secret code. You have just learned that their encryption method is based upon the ASCII code (you can find this set easily by searching online). Individual characters in a string are encoded using this system. For example, the letter ‘A’ is encoded using the number 65 and ‘B’ is encoded using the number 66.
Your enemy’s secret code takes each letter of the message and encrypts it as follows (using a secret key):
If (OriginalChar + Key > 126) then
    EncryptedChar = ((OriginalChar + Key) - 127) + 32
Else 
    EncryptedChar = (OriginalChar + Key)
For example, if the enemy uses Key = 10 then the message ”Hey” would be encrypted as:
Character   ASCII
H         72
e         101
y         121

Encrypted H = (72 + 10) = 82 = R in ASCII
Encrypted e = (101 + 10) = 111 = o in ASCII
Encrypted y = 32 + ((121 + 10) - 127) = 36 = $ in ASCII
Consequently, “Hey” would be transmitted as “Ro$”.
Write a program that decrypts the intercepted message. You only know that the key used is a number between 1 and 100. Your program should try to decode the message using all possible keys between 1 and 100. When you try the valid key, the message will make sense. For all other keys, the message will appear as gibberish.
HINT: You will need to implement a decrypt function that takes in an encrypted message as string and a key as integer and returns the decrypted message as string. You can decrypt each letter of the message as follows:
If (EncryptedChar - Key < 32) then
    DecryptedChar = ((EncryptedChar - Key) + 127) - 32
Else
    DecryptedChar = (EncryptedChar - Key)
NOTE: You should also implement an encrypt function that takes in a regular message as string and a key as integer and returns the corresponding encrypted message as string (the algorithm to encrypt a message is mentioned above in the problem description). This function would help you in encrypting any regular message, which then can be passed to your decrypt function to be decrypted.

For Encryption: You should ask the user for any regular message and a key and output the corresponding encrypted message.
Sample run:
Enter a regular message to encode:
Attack at dawn!
Enter a key value (between 0 and 100) for encoding:
88
The encoded message is: 
:mmZ\dxZmx]Zpgy

For Decryption: You should ask the user for an encrypted message and output 100 well-formatted, decrypted messages (using keys between 1 and 100) along with the corresponding key value.
Sample run (the gibberish messages below are not accurate):
Enter an encrypted message to decode:
:mmZ\dxZmx]Zpgy 
The following are the decoded messages for keys 1 to 100:
Key: 1 –> Decoded Message: whfuihwuiidh89
Key: 2 –> Decoded Message: 9ehkaOY3ewine
...
Key: 87 –> Decoded Message: Buubdl!bu!ebxo
Key: 88 –> Decoded Message: Attack at dawn!
...
Key: 100 –> Decoded Message: on3dwp389/wi8
This is the code I currently have:
def encrypt(message, key):
    result = ""
    for char in message:
        result += encryptedChar
    return result
shareimprove this question
  
The description of your problem seems daunting, but the solution is not that hard. You can use the built-instring datatype with the associated built-in functions and while loop (with 'len' function) or a forloop (with 'in' operator) to traverse the string. Also, use the 'chr' and 'ord' functions (which are based on ASCII code). – Brian Cain Nov 14 '13 at 17:43
  
You should try & use string.make_trans('plaintext', 'ciphertex') in the string library. – Ashish Nitin Patil Nov 14 '13 at 17:44
  
Yah i've read that about 500 times. Thanks! – TYPKRFT Nov 14 '13 at 17:45
  
the code you have probably raises an error? since you have no encryptedChar? it tells you exactly how to get the encrypted char ... – Joran Beasley Nov 14 '13 at 17:52 
  
Thanks Joran I have had no issues with most of the problems until now. I still dont understand how to do this, though. – TYPKRFT Nov 14 '13 at 17:54

2 Answers


Here is a simpler (but longer) answer as Joran Beasley's.
After you understand, that you can get the 'number' of a character with ord() and 'recover' the character with chr() it is quiet simple to 'translate' the code you got into correct python code.
Beginning with the following part:
If (OriginalChar + Key > 126) then
    EncryptedChar = ((OriginalChar + Key) - 127) + 32
Else 
    EncryptedChar = (OriginalChar + Key)
If you start out with the code you already wrote you can translate the above into:
def encrypt(message, key):
    result = ""
    for char in message:
        if (ord(char) + key > 126):
            result += chr(ord(char) + key - 127 + 32)
        else:
            result += chr(ord(char) + key)
    return result
You can do the same with the decryption part and write then a simple menu.
Here is the remaining code (you have to add the encrypt function at the top:
def decrypt(message):
    for key in range(1, 101):
        result = ""
        for char in message:
            if (ord(char) - key < 32):
                result += chr(ord(char) - key + 127 - 32)
            else:
                result += chr(ord(char) - key)
        print('key: {} -'.format(key), result)

if __name__ == '__main__':
    print('1 - Encrypt')
    print('2 - Decrypt')
    inp = input('select 1 or 2: ')
    if inp == '1':
        msg = input('Enter message: ')
        key = int(input('Enter key (1-100): '))
        print('Encrypted message:')
        print(encrypt(msg, key))
    else:
        msg = input('Enter message: ')
        decrypt(msg)
shareimprove this answer
  
I was trying to get him here :P (+1 all the same) – Joran Beasley Nov 14 '13 at 18:24 
  
I am going to try and comment every line of this.. could I private message either of you, maybe tom with the comment and maybe you can assess if I have grasped what I need to. I dont want to move on until I understand this like the back of my hand. – TYPKRFT Nov 14 '13 at 18:40 
1
I have created a so chatroom. You can post your questions/comments/... there. Now you, Joran Beasley, and I have write access, but everyone can see it. – TobiMarg Nov 14 '13 at 20:15
  
Thanks that is really too nice of you! – TYPKRFT Nov 15 '13 at 3:06

heres a fun solution
import string,codecs
class RotEncoder:
    def __init__(self,rot):
        self._rot = rot
    def _encChar(self,ch):
        return chr((ord(ch) + self._rot) if ord(ch) + self.rot =< 126 else  (((ord(ch) + self._rot) - 127) + 32))
    def _decChar(self,ch):
        return chr((ord(ch) - self._rot) if ord(ch) - self._rot >= 32 else (((ord(ch) - self._rot) + 127) - 32))
    def encode(self,txt,errors=[]):
        return "".join(map(self._encChar,txt)),1
    def decode(self,txt,errors=[]):
        return "".join(map(self._decChar,txt)),1
import re
def find_rot(search):
    t = re.match("rot\s?([0-9]+)",search.lower())
    if t.groups():
        val = int(t.groups()[0])
        return codecs.CodecInfo(
            name='rotcipher',
            encode=RotEncoder(val).encode,
            decode=RotEncoder(val).decode
            )

codecs.register(find_rot)

print ":mmZ\dxZmx]Zpgy".decode('rot88')
shareimprove this answer
  
Sorry that is way way above my head. I appreciate your input though. – TYPKRFT Nov 14 '13 at 18:03
  
ok what part of the original assignment do you not understand? maybe that would be a better question ... because from where I sit it looks like you posted your assignment and just wanted an answer ... so why do you think your existing solution does not work? – Joran Beasley Nov 14 '13 at 18:10
  
Well I am new and I dont understand how to break it down. I feel like I got through the lessons fine...then bam no clue. I know that I need two functions one for the encrypt and one for the decrypt. I know the encrypt needs to take in a message and a key 1-100 i think. I think that I need to grab the ascii value for each character but Im stuck after that. – TYPKRFT Nov 14 '13 at 18:16
  
so do you know how to get the ascii value for a character? if so why is that not part of your "attempt" above?– Joran Beasley Nov 14 '13 at 18:17
  
An answer would be helpful. I have answered most of my own questions on here but am just baffled by this. The instructions are becoming lost in translation to me and I don't know anyone else that knows this kind of stuff..That is why I am on here. I fear that I have gotten to a stuck point and will not understand python past this. – TYPKRFT Nov 14 '13 at 18:19
  
I know what needs to be done I think but I dont know how to write it. I know that I need to do ord() for each character right? – TYPKRFT Nov 14 '13 at 18:20
1
ok thats a good start ... so you have originalChar as char in your attempt above... what do you need to do to get encryptedChar? as far as an answer... if thats all you want I gave it above ... if you want to understand both the problem and the solution I will do my best to walk you to that... once you understand what you need to do here you can apply it to many other problems – Joran Beasley Nov 14 '13 at 18:21 
1
This answer is short, very nice and useful if one has a bit more experience with python, but hard to understand for a beginner. So I added a simpler answer (but not with such an elegant code). – TobiMarg Nov 14 '13 at 18:26
  
Joran I am still lost I appreciate your trying to hold my hand through this. I fear that maybe going back to school for something other than computer science will be in my future. Do you have any recommendations on maybe something I have missed in my studies and should have a better understanding of? – TYPKRFTNov 14 '13 at 18:31
1
it just takes practice ... and being able to recognize the class of problem and know what potential solutions are to that class of problem ... there is no innate programmer gene ... you just need to work at it (I posted this answer specifically because I knew it would make no sense to a beginner and I wanted you to make the logic leap on your own(with some help), believe me it happens you will be totally lost and all of a sudden some small thing will click and you will fully understand both the problem and the solution) ... 

http://stackoverflow.com/questions/19984548/how-can-i-tackle-this-cryptography

Tuesday, January 5, 2016

COUNTERFEITERS STOCK UP ON HAIRSPRAY

This story from the Los Angeles Times describes the bust of a counterfeiting operation making high-quality queer. The counterfeiters used hairspray on their bills to fool anti-counterfeiting pens.
On Tuesday, federal authorities announced that Stroud and four other men have been arrested and charged in connection with a massive counterfeiting scheme that U.S. Atty. Thomas P. O'Brien called "one of the largest, if not the largest, counterfeit currency rings we have seen in Southern California."

Hairspray Counterfeiters

The ring is responsible for printing and distributing nearly $7 million in bogus currency over the last two years, authorities said.

Assistant U.S. Atty. Tracy L. Wilkison, the prosecutor on the case, said it was unusual not just because of the amount of money, but because agents were able to go up the food chain in their investigation.

"Most of the time what we have is a handful of poorly crafted bills in small amounts," she said. "When we're able to trace it all the way back to the source and stop the printing, that's a big coup."

The bills, allegedly produced with computers and ink jet printers, were of particular concern to agents because they had proved difficult to detect and were passed in locations across the United States.

A search of Talton's home turned up "a full-scale counterfeit currency manufacturing plant" and more than $1 million in completed and partially completed fake bills, according to an affidavit filed in U.S. District Court in Los Angeles. Among the evidence found in the baldheaded suspect's trash were 20 bottles of Aqua Net and White Rain hair spray.

Authorities say the hair product is commonly used to coat fake bills to block the counterfeit-detecting pens used by merchants.

As he was being taken into custody, Talton admitted that he had printed between $5 million and $6 million in fake currency, authorities said.

To read the complete article, see: Five arrested after Secret Service probe into Southern California counterfeit ring 


http://www.coinbooks.org/esylum_v11n20a23.html


Does vitamin C defeat counterfeit test pens

My test strips showing too strong, too weak, and just right.
From left to right, test sheets have been treated with 0.000, 0.007, 0.015, 0.030, 0.060, and 0.120 M ascorbic acid from ground vitamin pills, allowed to dry, ad marked with a counterfeit test pen. The 0.030 M solution produces a stable color that is very close to the mark on a real US $20 note, top. That color only becomes stable after about 30 seconds, however, and the visible color change over time is not seen on authentic bills.
Well, sort of.
Some time ago, a friend reported to me a rumor he’d heard that Aqua Net hairspray could be applied to regular paper to defeat a counterfeit test pen. I tested it, and found it wasn’t true, at least not with the kind of Aqua Net I used. But in the course of reading up to perform that test I learned that counterfeit test pens work by the common starch-iodine reaction: Iodine and starch create a complex species that has a distinct blue-black color. Currency paper has no starch in it, whereas most common paper does. So if your paper turns blue on exposure to iodine that’s a pretty good sign it isn’t real currency paper. That, or some jerk has treated your real money with spray-on laundry starch which (though I haven’t tested this, yet), would probably make real currency paper test as counterfeit.
Anyway, so I knew from that little experiment how the pens work, and when a buddy at MAKE recently rehashed our invisible inkjet printer project from Vol 16, I realized that the chemistry in use there, in which vitamin C inhibits the starch-iodine reaction to develop an invisible ink, might well imply that a solution of vitamin C would also defeat the same reaction when it’s used in a counterfeit test pen.
Turns out I was kind of right. Just kind of. A 0.030 M solution of vitamin C (ascorbic acid) made from ground-up vitamin supplements gives the counterfeit pen a stable color on normal office copy paper that is hard to distinguish, visually, from the color of the pen on a real banknote. Trouble is, it takes awhile to reach that stable color. Like 30 to 45 seconds. It’s darker, at first, and then fades. Stronger solutions of vitamin C make the mark fade more rapidly and to a lighter color than is “correct,” whereas weaker solutions do not fade the mark as much and leave a darker color than is “correct.” Specific experimental details are in small print below.
So, it appears to me that vitamin C does not actually “inhibit” the starch-iodine reaction; rather, it out-competes it energetically. The product of the reaction of vitamin C with iodine is, I think, more stable than the starch-iodine complex, but the starch-iodine complex forms faster. So you get a visibly dark starch-iodine reaction which fades to a lighter color as the iodine is drawn off to react with vitamin C.
10 x 1000mg vitamin C tablets were ground in a mortar and pestle and stirred overnight with 2 cups carbon-filtered tap water to prepare a 0.120 M solution of ascorbic acid (and possibly other pill ingredients that have not been identified or controlled for). Serial dilution produced solutions of 0.060, 0.030, 0.015, and 0.007 M concentrations. Water from the same source was used as a control. Bill-sized pieces of Office Depot copy paper were cut, rolled, and each soaked overnight in a test tube containing one of the six test solutions. The next day, the rolled papers were removed from the test tubes, unrolled by hand, and couched on separate folded paper towels to dry overnight. They were then taped to a piece of plate glass and an approximately 1-inch mark was applied using a commercial counterfeit test marker. A new US $20 note was also marked for comparison. The samples were photographed immediately, and after one-half hour. The samples were marked again, and each mark filmed to record the first 30 seconds of the color reaction’s time course. The 0.030 M solution was found to give stable color that very closely matched the marked reference bill by visual inspection. Weaker solutions gave darker marks that were not deceptive, and stronger solutions gave faint or completely absent marks.

2 THOUGHTS ON “DOES VITAMIN C DEFEAT COUNTERFEIT TEST PENS?

  1. So what your saying is, beware test marks already on a bill because the final color of the Vitamin C is the same as the final color on the real banknote.
  2. http://www.smragan.com/2011/05/16/does-vitamin-c-defeat-counterfeit-test-pens/
Resumo US 6362348 B1
http://www.google.com/patents/US6362348
An additive for inkjet printing, comprising a stabilized ascorbic acid derivative. Also disclosed are a recording solution, a method for preventing discoloration and fading of an image, and a recording sheet, each using the additive. The color change of an image can be prevented by incorporating the stabilized ascorbic acid derivative into an inkjet-printed image.

http://www.theimagingwarehouse.com/ProductGrp/Kodak-Xtol
Xtol is a low toxicity ascorbic acid developer with very high image quality at full emulsion speed and is suitable for most professional black-and-white films. Characteristics are convenient, room-temperature mixing, fine grain and high sharpness. Provides more emulsion speed (shadow detail) than most developers for normal and push processing.
Makes 5L stock solution. Can be used as stock or diluted 1+1, 1+2, 1+3
Supplied as powder.

Wednesday, December 16, 2015

BLACKOUTS GRAPHITE GRENADES


Explosive Potential of Graphite Dust
Combustible dust is identified as, "Any finely divided solid material that is 420 microns or smaller in diameter (material passing a U.S. No. 40 Standard Sieve) and presents a fire or explosion hazard when dispersed and ignited in air."² The elements of fire include fuel, oxygen and ignition. A dust fire or deflagration occurs when sufficient concentrations of fine particulates are suspended in air and then exposed to a source of ignition such as a spark or welding igniter. This ultimately results in the igniting or combustion of the dust.

THE REST OF THE GRENADE COMPOSITION: 
High speed automatic mechanical pressing is commonly used to volumetricaHy load small quantities of primary explosives into blasting caps and detonators and to make small explosive components. Primary explosives may be mixed with graphite to improve flow and antistatic properties, or may be desensitized with waxes, stearates, or polymeric compounds. Secondary explosives and explosive mixtures may be pressed to form booster pellets or to load components directiy as in the case of armor-penetrating projectiles. Where the explosive is too sensitive in its pure crystalline state to permit press loading or lacks the requited mechanical properties in its compressed state for subsequent use, it is coated with polymeric materials such as polystyrene and polybutadiene, to form mol ding powders, often referred to as plastic-bonded explosives. Desensitization is obtained when the explosive crystals are thoroughly and uniformly coated. A typical procedure for making PBX-type explosives involves making a lacquer of a solution of the organic polymer in a solvent, eg, ethylacetate, and a dding it to a water slurry of the explosive. The solvent is distilled off under vacuum while the mix is agitated, precipitating the polymer on the explosive. The coated explosive forms small agglomerates as the solvent removal process continues. It is filtered, washed, and vacuum dried to form a free-fiowing, dustiess, high density powder. Bi- or trimodal size distributions of spherical shaped explosive particles are often used to improve the flow characteristics and packing density of the mol ding powder. Antistatic agents (qv) such as carbon black may be added to prevent dust explosions. In another coating technique, the requited amount of low melting wax is added to a water slurry of the explosive at a temperature high enough to melt the wax. After agitation to distribute the wax on the crystals, the temperature is lowered, the water decanted, and the remaining mass filtered and dried

NON METALLIC COMPOSITES

How are ceramic blade knives detected through airport security

Best Answer:  By the metal pins used to attach the handles
If you're sending it through the X-Ray machine, very easily. X-Rays are blocked by things that have high molecular weights. Most ceramic knives are made from Zirconium Oxide. Zr has a molecular weight of 40. Much higher than the 26 of Iron, the principal component of a steel knife. Another common material is Aluminum Oxide, but these are stabilized with Zirconium or Yttrium (39), making them easier to detect. 


Beryllium Copper Springs http://www.indiamart.com/hyderabadsprings-components/compression-springs.html#beryllium-copper-springs

the tiny springs are made from Beryllium Copper to eliminate any magnetic signature. Its handle is made from fibre resin and the razor sharp, partially serrated blade is made of 33% glass fibre Nylon 66

Hybrid long glass+carbon fiber reinforced composites http://www.plasticomp.com/hybrid-long-glass-carbon-fiber/ 

Audi A8 spare wheel recess employs reinforced polyamide http://www.materialstoday.com/composite-applications/news/audi-a8-spare-wheel-recess-employs-reinforced/


Portable, open source Fusion 3D Printer now available for $249, Kickstarter forthcoming http://www.3ders.org/articles/20150907-portable-open-source-fusion-3d-printer-now-available-kickstarter-forthcoming.html


Non-metallic, high-tech materials
Some of the most common non-metallic high-tech materials manufactured and used in the making of knives are:

* black woven graphite composite: so hard it has to be cut with a diamond-tipped blade, using water for a lubricant
* carbon fibre sheet - Immensely strong crystalline filaments of carbon in resin
* celluloid - transparent plastic made from camphor and nitrocellulose
* delrin - a very strong, pure white, plastic material used for knife handles
* kydex - a very strong and sophisticated acrylic-PVC alloy thermoplastic material... ican be heat-moulded, sawn, ground, milled and polished and may also be joined to itself or other materials with an unbreakable bond using a hot glass welding technique
* neoprene a rubber-like compound used as a non-slip knife handle grip
* polyvinyl chloride (PVC) - a durable plastic which can be machined and worked to manufacture knives with standard tools
* zytel - a hard and durable form of nylon used to make many kinds of knives and weapons
* Blackie Collins CIA Folder. There is no steel whatsoever in this spring-assisted, folding lock knife. This assisted opening feature is made possible by a patented internal strut mechanism. The tiny springs are made from Beryllium Copper to eliminate any magnetic signature. Its handle is made from fibre resin and the razor sharp, partially serrated blade is made of 33% glass fibre Nylon 66
CIA Letter Opener
Manufactured from high-tech composite materials with over 60% glass fibres, the CIA Letter Opener's marketing blurb describes it as 'a completely non-metallic knife that provides superior plunging power as well as a hard edge. The scalloped serrations on both sides of the blade give additional opening power on fibrous materials'. For many years the CIA Letter Opener has been described as a lightweight security device capable of being driven through over 12 mm of plywood without breaking. The Cold Steel CAT Tanto, meanhwile, is marketed as being 'black, silent and totally undetectable'. The CAT, as it's known, is made from UV and heat-stabilised, glass-filled zytel nylon. This knife, with its sure-grip handle, reinforced Tanto point and skull-crushing pommel is a super-light, full-size killing tool that is invisible to metal screening devices and would probably pass unnoticed through any security checks. The CAT has all the cutting and penetrating power of its steel sisters. The Cold Steel Vietnam Delta Dart is best described as a vicious weapon designed as a covert operations last-ditch, self-defence tool. The Delta Dart is 8" long and 1/2" in diameter, yet it weighs only half an ounce! The handle is knurled for a positive grip and the butt smooth and rounded, so it's perfect for both thumb and palm reinforced grip positions. The triangular blade geometry gives it incredible puncturing ability. The Delta Dart is made entirely of 43% glass-filled zytel nylon, which is easily sharpened with a nail file. Then there's the Lansky LS17. Although marketed as a general-purpose knife, the LS17 or 'The Knife', as it is sometimes referred to, has become known as a clandestine fighting weapon. The Knife is made from ABS plastic with a 31/2'' double-edged spear point blade with a serrated edge on one side. The non-slip handle has finger grooves and a thumb rest for extra thrusting grip. The LS17 is invisible to metal screening devices.
The Ace of Spades
The Ace of Spades is a very nasty push dagger made from ABS plastic. It is an extremely robust one-piece construction, capable of massive penetration with its razor sharp, spear point configuration. Of course not all non-metallic knives are manufactured as weapons. There are many companies that use advanced ceramics to create cutting tools and products which combine elegance and strength. Ceramic products using materials such as zirconium oxide and aluminium oxide for applications requiring chemically inert, non-magnetic, non-conductive or non-contaminating materials are also perfect for general applications requiring superior edge retention or wear resistance. They're also ideal for special applications such as EOD work. Many of these weapons have been designed and manufactured for no other reason than to compromise security and endanger life. As I have said many times before in my writings and my training programmes: "You cannot rely on technology alone when it comes to weapons detection, and it makes absolutely no difference whatsoever how much sophisticated state-of-the-art detection equipment you have at your disposal... If you have not trained your personal to understand what kind of weapon they are looking for, what they could be made from or even what they look like, they will not find them!"
All you need to know about PS5
PS5is a nationally-recognised, specialist security consultancy and training provider to the law enforcement, defence and security industries worldwide. The company's training wing 'REACT' delivers highly specialised training protocols to professionals operating across the private and public sectors with specific focus on weapons awareness and personal protection from violence, aggressive behaviour and terrorism. In order to carry out certain aspects of its work, the company has been granted a UK Government Home Office Authority directly approved by the Secretary of State under Section 5. Due to the highly sensitive and sometimes restricted nature of PS5's work, and in order to maintain a high level of security and confidentiality, the company has its own in-house, fully comprehensive, design, photographic and video production capability. This department's primary remit is the design, production and publication of training and educational material as well as the creation of the company's own corporate in-house journal, PCW Review. This PS5 publication is distributed to law enforcement and security professionals in over fifty countries. PS5 also designs, develop and produce a range of security related safety products and training aids.


radio frequency detection of guns ( 3mm of metal for 100mm of range) jamming antennas