mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 15:26:16 -04:00
Initial pages commit
This commit is contained in:
parent
b1d73a725d
commit
56dbb3fa40
376 changed files with 252899 additions and 88317 deletions
530
docs/operations_BitwiseOp.js.html
Executable file
530
docs/operations_BitwiseOp.js.html
Executable file
|
@ -0,0 +1,530 @@
|
|||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<title>CyberChef Source: operations/BitwiseOp.js</title>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-default navbar-fixed-top navbar-inverse">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<a class="navbar-brand" href="index.html"><img class="branding-logo" src="../build/prod/images/cyberchef-32x32.png"
|
||||
alt="logo"/>CyberChef</a>
|
||||
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="navbar-collapse collapse" id="topNavigation">
|
||||
<ul class="nav navbar-nav">
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b class="caret"></b></a>
|
||||
<ul class="dropdown-menu inline">
|
||||
<li><a href="FlowControl.html">FlowControl</a></li><li><a href="Utils.html">Utils</a></li><li><a href="Base.html">Base</a></li><li><a href="Base64.html">Base64</a></li><li><a href="BitwiseOp.html">BitwiseOp</a></li><li><a href="ByteRepr.html">ByteRepr</a></li><li><a href="CharEnc.html">CharEnc</a></li><li><a href="Checksum.html">Checksum</a></li><li><a href="Cipher.html">Cipher</a></li><li><a href="Code.html">Code</a></li><li><a href="Compress.html">Compress</a></li><li><a href="Convert.html">Convert</a></li><li><a href="DateTime.html">DateTime</a></li><li><a href="Endian.html">Endian</a></li><li><a href="Entropy.html">Entropy</a></li><li><a href="Extract.html">Extract</a></li><li><a href="FileType.html">FileType</a></li><li><a href="HTML.html">HTML</a></li><li><a href="HTTP.html">HTTP</a></li><li><a href="Hash.html">Hash</a></li><li><a href="Hexdump.html">Hexdump</a></li><li><a href="IP.html">IP</a></li><li><a href="JS.html">JS</a></li><li><a href="MAC.html">MAC</a></li><li><a href="Numberwang.html">Numberwang</a></li><li><a href="OS.html">OS</a></li><li><a href="PublicKey.html">PublicKey</a></li><li><a href="Punycode.html">Punycode</a></li><li><a href="QuotedPrintable.html">QuotedPrintable</a></li><li><a href="Rotate.html">Rotate</a></li><li><a href="SeqUtils.html">SeqUtils</a></li><li><a href="StrUtils.html">StrUtils</a></li><li><a href="Tidy.html">Tidy</a></li><li><a href="URL_.html">URL_</a></li><li><a href="UUID.html">UUID</a></li><li><a href="Unicode.html">Unicode</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b class="caret"></b></a>
|
||||
<ul class="dropdown-menu inline">
|
||||
<li><a href="Chef.html">Chef</a></li><li><a href="Dish.html">Dish</a></li><li><a href="Ingredient.html">Ingredient</a></li><li><a href="Operation.html">Operation</a></li><li><a href="Recipe.html">Recipe</a></li><li><a href="ControlsWaiter.html">ControlsWaiter</a></li><li><a href="HTMLApp.html">HTMLApp</a></li><li><a href="HTMLCategory.html">HTMLCategory</a></li><li><a href="HTMLIngredient.html">HTMLIngredient</a></li><li><a href="HTMLOperation.html">HTMLOperation</a></li><li><a href="HighlighterWaiter.html">HighlighterWaiter</a></li><li><a href="InputWaiter.html">InputWaiter</a></li><li><a href="Manager.html">Manager</a></li><li><a href="OperationsWaiter.html">OperationsWaiter</a></li><li><a href="OptionsWaiter.html">OptionsWaiter</a></li><li><a href="OutputWaiter.html">OutputWaiter</a></li><li><a href="RecipeWaiter.html">RecipeWaiter</a></li><li><a href="SeasonalWaiter.html">SeasonalWaiter</a></li><li><a href="WindowWaiter.html">WindowWaiter</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="events.list.html" class="dropdown-toggle" data-toggle="dropdown">Events<b class="caret"></b></a>
|
||||
<ul class="dropdown-menu inline">
|
||||
<li><a href="Manager.html#event:appstart">Manager#event:appstart</a></li><li><a href="Manager.html#event:operationadd">Manager#event:operationadd</a></li><li><a href="Manager.html#event:operationremove">Manager#event:operationremove</a></li><li><a href="Manager.html#event:oplistcreate">Manager#event:oplistcreate</a></li><li><a href="Manager.html#event:statechange">Manager#event:statechange</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b class="caret"></b></a>
|
||||
<ul class="dropdown-menu inline">
|
||||
<li><a href="global.html#Categories">Categories</a></li><li><a href="global.html#OperationConfig">OperationConfig</a></li><li><a href="global.html#main">main</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
<div class="col-sm-3 col-md-3">
|
||||
<form class="navbar-form" role="search">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" placeholder="Search" name="q" id="search-input">
|
||||
<div class="input-group-btn">
|
||||
<button class="btn btn-default" id="search-submit"><i class="glyphicon glyphicon-search"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="container" id="toc-content">
|
||||
<div class="row">
|
||||
|
||||
|
||||
<div class="col-md-12">
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
<h1 class="page-title">Source: operations/BitwiseOp.js</h1>
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre
|
||||
class="sunlight-highlight-javascript linenums">/* globals CryptoJS */
|
||||
|
||||
/**
|
||||
* Bitwise operations.
|
||||
*
|
||||
* @author n1474335 [n1474335@gmail.com]
|
||||
* @copyright Crown Copyright 2016
|
||||
* @license Apache-2.0
|
||||
*
|
||||
* @namespace
|
||||
*/
|
||||
var BitwiseOp = {
|
||||
|
||||
/**
|
||||
* Runs bitwise operations across the input data.
|
||||
*
|
||||
* @private
|
||||
* @param {byte_array} input
|
||||
* @param {byte_array} key
|
||||
* @param {function} func - The bitwise calculation to carry out
|
||||
* @param {boolean} null_preserving
|
||||
* @param {boolean} differential
|
||||
* @returns {byte_array}
|
||||
*/
|
||||
_bit_op: function (input, key, func, null_preserving, differential) {
|
||||
if (!key || !key.length) key = [0];
|
||||
var result = [],
|
||||
x = null,
|
||||
k = null,
|
||||
o = null;
|
||||
|
||||
for (var i = 0; i < input.length; i++) {
|
||||
k = key[i % key.length];
|
||||
o = input[i];
|
||||
x = null_preserving && (o === 0 || o == k) ? o : func(o, k);
|
||||
result.push(x);
|
||||
if (differential && !(null_preserving && (o === 0 || o == k))) {
|
||||
key[i % key.length] = x;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
XOR_PRESERVE_NULLS: false,
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
XOR_DIFFERENTIAL: false,
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
KEY_FORMAT: ["Hex", "Base64", "UTF8", "UTF16", "UTF16LE", "UTF16BE", "Latin1"],
|
||||
|
||||
/**
|
||||
* XOR operation.
|
||||
*
|
||||
* @param {byte_array} input
|
||||
* @param {Object[]} args
|
||||
* @returns {byte_array}
|
||||
*/
|
||||
run_xor: function (input, args) {
|
||||
var key = Utils.format[args[0].option].parse(args[0].string || ""),
|
||||
null_preserving = args[1],
|
||||
differential = args[2];
|
||||
|
||||
key = Utils.word_array_to_byte_array(key);
|
||||
|
||||
return BitwiseOp._bit_op(input, key, BitwiseOp._xor, null_preserving, differential);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
XOR_BRUTE_KEY_LENGTH: ["1", "2"],
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
XOR_BRUTE_SAMPLE_LENGTH: 100,
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
XOR_BRUTE_SAMPLE_OFFSET: 0,
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
XOR_BRUTE_PRINT_KEY: true,
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
XOR_BRUTE_OUTPUT_HEX: false,
|
||||
|
||||
/**
|
||||
* XOR Brute Force operation.
|
||||
*
|
||||
* @param {byte_array} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run_xor_brute: function (input, args) {
|
||||
var key_length = parseInt(args[0], 10),
|
||||
sample_length = args[1],
|
||||
sample_offset = args[2],
|
||||
null_preserving = args[3],
|
||||
differential = args[4],
|
||||
crib = args[5],
|
||||
print_key = args[6],
|
||||
output_hex = args[7],
|
||||
regex;
|
||||
|
||||
var output = "",
|
||||
result,
|
||||
result_utf8;
|
||||
|
||||
input = input.slice(sample_offset, sample_offset + sample_length);
|
||||
|
||||
if (crib !== "") {
|
||||
regex = new RegExp(crib, "im");
|
||||
}
|
||||
|
||||
|
||||
for (var key = 1, l = Math.pow(256, key_length); key < l; key++) {
|
||||
result = BitwiseOp._bit_op(input, Utils.hex_to_byte_array(key.toString(16)), BitwiseOp._xor, null_preserving, differential);
|
||||
result_utf8 = Utils.byte_array_to_utf8(result);
|
||||
if (crib !== "" && result_utf8.search(regex) === -1) continue;
|
||||
if (print_key) output += "Key = " + Utils.hex(key, (2*key_length)) + ": ";
|
||||
if (output_hex)
|
||||
output += Utils.byte_array_to_hex(result) + "\n";
|
||||
else
|
||||
output += Utils.printable(result_utf8, false) + "\n";
|
||||
if (print_key) output += "\n";
|
||||
}
|
||||
return output;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* NOT operation.
|
||||
*
|
||||
* @param {byte_array} input
|
||||
* @param {Object[]} args
|
||||
* @returns {byte_array}
|
||||
*/
|
||||
run_not: function (input, args) {
|
||||
return BitwiseOp._bit_op(input, null, BitwiseOp._not);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* AND operation.
|
||||
*
|
||||
* @param {byte_array} input
|
||||
* @param {Object[]} args
|
||||
* @returns {byte_array}
|
||||
*/
|
||||
run_and: function (input, args) {
|
||||
var key = Utils.format[args[0].option].parse(args[0].string || "");
|
||||
key = Utils.word_array_to_byte_array(key);
|
||||
|
||||
return BitwiseOp._bit_op(input, key, BitwiseOp._and);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* OR operation.
|
||||
*
|
||||
* @param {byte_array} input
|
||||
* @param {Object[]} args
|
||||
* @returns {byte_array}
|
||||
*/
|
||||
run_or: function (input, args) {
|
||||
var key = Utils.format[args[0].option].parse(args[0].string || "");
|
||||
key = Utils.word_array_to_byte_array(key);
|
||||
|
||||
return BitwiseOp._bit_op(input, key, BitwiseOp._or);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* ADD operation.
|
||||
*
|
||||
* @param {byte_array} input
|
||||
* @param {Object[]} args
|
||||
* @returns {byte_array}
|
||||
*/
|
||||
run_add: function (input, args) {
|
||||
var key = Utils.format[args[0].option].parse(args[0].string || "");
|
||||
key = Utils.word_array_to_byte_array(key);
|
||||
|
||||
return BitwiseOp._bit_op(input, key, BitwiseOp._add);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* SUB operation.
|
||||
*
|
||||
* @param {byte_array} input
|
||||
* @param {Object[]} args
|
||||
* @returns {byte_array}
|
||||
*/
|
||||
run_sub: function (input, args) {
|
||||
var key = Utils.format[args[0].option].parse(args[0].string || "");
|
||||
key = Utils.word_array_to_byte_array(key);
|
||||
|
||||
return BitwiseOp._bit_op(input, key, BitwiseOp._sub);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* XOR bitwise calculation.
|
||||
*
|
||||
* @private
|
||||
* @param {number} operand
|
||||
* @param {number} key
|
||||
* @returns {number}
|
||||
*/
|
||||
_xor: function (operand, key) {
|
||||
return operand ^ key;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* NOT bitwise calculation.
|
||||
*
|
||||
* @private
|
||||
* @param {number} operand
|
||||
* @returns {number}
|
||||
*/
|
||||
_not: function (operand, _) {
|
||||
return ~operand & 0xff;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* AND bitwise calculation.
|
||||
*
|
||||
* @private
|
||||
* @param {number} operand
|
||||
* @param {number} key
|
||||
* @returns {number}
|
||||
*/
|
||||
_and: function (operand, key) {
|
||||
return operand & key;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* OR bitwise calculation.
|
||||
*
|
||||
* @private
|
||||
* @param {number} operand
|
||||
* @param {number} key
|
||||
* @returns {number}
|
||||
*/
|
||||
_or: function (operand, key) {
|
||||
return operand | key;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* ADD bitwise calculation.
|
||||
*
|
||||
* @private
|
||||
* @param {number} operand
|
||||
* @param {number} key
|
||||
* @returns {number}
|
||||
*/
|
||||
_add: function (operand, key) {
|
||||
return (operand + key) % 256;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* SUB bitwise calculation.
|
||||
*
|
||||
* @private
|
||||
* @param {number} operand
|
||||
* @param {number} key
|
||||
* @returns {number}
|
||||
*/
|
||||
_sub: function (operand, key) {
|
||||
var result = operand - key;
|
||||
return (result < 0) ? 256 + result : result;
|
||||
},
|
||||
|
||||
};
|
||||
</pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="modal fade" id="searchResults">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title">Search results</h4>
|
||||
</div>
|
||||
<div class="modal-body"></div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div>
|
||||
|
||||
|
||||
<footer>
|
||||
|
||||
|
||||
<span class="copyright">
|
||||
© Crown Copyright 2016
|
||||
</span>
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a>
|
||||
|
||||
on Mon Nov 28th 2016
|
||||
|
||||
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
|
||||
<script src="scripts/docstrap.lib.js"></script>
|
||||
<script src="scripts/toc.js"></script>
|
||||
|
||||
<script type="text/javascript" src="scripts/fulltext-search-ui.js"></script>
|
||||
|
||||
|
||||
<script>
|
||||
$( function () {
|
||||
$( "[id*='$']" ).each( function () {
|
||||
var $this = $( this );
|
||||
|
||||
$this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
|
||||
} );
|
||||
|
||||
$( ".tutorial-section pre, .readme-section pre, pre.prettyprint.source" ).each( function () {
|
||||
var $this = $( this );
|
||||
|
||||
var example = $this.find( "code" );
|
||||
exampleText = example.html();
|
||||
var lang = /{@lang (.*?)}/.exec( exampleText );
|
||||
if ( lang && lang[1] ) {
|
||||
exampleText = exampleText.replace( lang[0], "" );
|
||||
example.html( exampleText );
|
||||
lang = lang[1];
|
||||
} else {
|
||||
var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/);
|
||||
lang = langClassMatch ? langClassMatch[1] : "javascript";
|
||||
}
|
||||
|
||||
if ( lang ) {
|
||||
|
||||
$this
|
||||
.addClass( "sunlight-highlight-" + lang )
|
||||
.addClass( "linenums" )
|
||||
.html( example.html() );
|
||||
|
||||
}
|
||||
} );
|
||||
|
||||
Sunlight.highlightAll( {
|
||||
lineNumbers : true,
|
||||
showMenu : true,
|
||||
enableDoclinks : true
|
||||
} );
|
||||
|
||||
$.catchAnchorLinks( {
|
||||
navbarOffset: 10
|
||||
} );
|
||||
$( "#toc" ).toc( {
|
||||
anchorName : function ( i, heading, prefix ) {
|
||||
return $( heading ).attr( "id" ) || ( prefix + i );
|
||||
},
|
||||
selectors : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4",
|
||||
showAndHide : false,
|
||||
smoothScrolling: true
|
||||
} );
|
||||
|
||||
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
||||
$( '.dropdown-toggle' ).dropdown();
|
||||
|
||||
$( "table" ).each( function () {
|
||||
var $this = $( this );
|
||||
$this.addClass('table');
|
||||
} );
|
||||
|
||||
} );
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<!--Navigation and Symbol Display-->
|
||||
|
||||
|
||||
<!--Google Analytics-->
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
SearcherDisplay.init();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue